# GraphBinMatch: Graph-based Similarity Learning for Cross-Language Binary and
Source Code Matching

Ali TehraniJamsaz, Hanze Chen, Ali Jannesari
Iowa State University, Ames, Iowa, USA {tehrani, hanzech,
<EMAIL_ADDRESS>
###### Abstract

Matching binary to source code and vice versa has various applications in
different fields, such as computer security, software engineering, and reverse
engineering. Even though there exist methods that try to match source code
with binary code to accelerate the reverse engineering process, most of them
are designed to focus on one programming language. However, in real life,
programs are developed using different programming languages depending on
their requirements. Thus, cross-language binary-to-source code matching has
recently gained more attention. Nonetheless, the existing approaches still
struggle to have precise predictions due to the inherent difficulties when the
problem of matching binary code and source code needs to be addressed across
programming languages.

In this paper, we address the problem of cross-language binary source code
matching. We propose GraphBinMatch, an approach based on a graph neural
network that learns the similarity between binary and source codes. We
evaluate GraphBinMatch on several tasks, such as cross-language binary-to-
source code matching and cross-language source-to-source matching. We also
evaluate our approach’s performance on single-language binary-to-source code
matching. Experimental results show that GraphBinMatch outperforms state-of-
the-art significantly with improvements as high as 15% over the F1 score.

###### Index Terms:

cross-language, code similarity, binary-source matching

##  I Introduction

Binary code is a collection of instructions that can be executed by computing
systems directly, whereas source code, which programmers write, is readable
and understandable. Binary-to-source code matching is a technique to evaluate
the likeliness of binary code and source code. This is an important aspect of
many security software engineering tasks, such as vulnerability [1] and
malware detection[2] and reverses engineering[3, 4].

Typically, when it comes to matching a binary code to a source code, we either
want to find the match for the binary file or the source code file. For
example, when we have a binary code fragment, it would be helpful to retrieve
its similar source code snipped, which can be used in a reverse engineering
task. The retired source code snipped enables researchers to understand what a
binary code fragment does. From the other aspect, if we have a source code
snipped with a vulnerability, matching it to a binary code form helps to
identify whether the vulnerability exists in the binary file.

Existing approaches try to measure the semantic similarity between binary and
source code. However, most works focus on matching binary to binary or source
code to source code [5, 6, 7]. Binary-to-source code is a non-trivial task as
two modalities are involved: binary and source codes. Lately, recent works
have been trying to measure the similarity between binary and source code;
however, they fall short in matching binary-to-source code across different
programming languages. Recently, Gui et al.[8] proposed a transformer-based
neural network to learn the similarity of binary and source code across
programming languages; they use Intermediate Representation (IR) as input data
for their model. However, they treat IR as a sequence of tokens; thus, their
model struggles to learn the similarity across programming languages.

In this paper, we present GraphBinMatch. An approach based on a graph neural
network to learn the semantic similarities between binary and source code.
Unlike previous approaches, Binary and source code are tread as graphs by
leveraging three types of flows: Control flow, data flow, and call flow.
Presenting binary and source codes as graphs helps the neural network model
better learn the code’s structure and semantics since the source code contains
specific structures, unlike natural language text.

Experimental results show that GraphBinMatch outperforms state-of-the-art
approaches by increasing F1 from 0.65 to 0.79, recall from 0.59 to 0.82, and
precision from 0.73 to 0.76.

Overall, the major contributions of this paper are:

  1. 1.

Formulating the problem as learning the similarities between graphs.

  2. 2.

Developing a special graph neural network as the backbone of GraphBinMatch to
learn the similarity of graphs.

  3. 3.

Evaluation of GraphBinMatch on a comprehensive set of tasks.

  4. 4.

Effectiveness of the approach not just for cross-language but also single-
language.

  5. 5.

Up to 15% improvement in comparison to state-of-the-art approach.

The rest of the paper is structured as follows: We first formulate the binary-
source matching problem in section II. Then, in section III, our proposed
approach is outlined and explained. Experimental setups are discussed and
explained in section IV. Section V presents the evaluation results, followed
by section VI in which we discuss some of the insights. Next, in section VII,
we provide an overview of related works, and lastly, section VIII concludes
the paper and explains the future works.

##  II Formulating the Problem

We formulate cross-language binary code-matching detection as follows: Given
two programs $P_{a}$ as binary and $P_{b}$ as source written in two different
programming languages, we aim to train a deep learning model to learn the
function $\gamma$, which can predict whether the two input programs are a
binary-code matching pair or non-binary-code matching pair.

The training set consists of triples $(P_{a},P_{b},y_{ab})$ where $y_{ab}$ is
the label. We consider all pairs of binary and source programs collected from
the same coding task in the dataset as positive samples and label them as 1,
indicating that they are binary-source matches. Conversely, we consider all
pairs of binary and source programs generated from different tasks in the
dataset as negative samples and label them as 0, indicating that they are non-
binary-source matches.

$\gamma(P_{a},P_{b})=\begin{cases}1,&\text{if $P_{a}$ and $P_{b}$ are
matching}\\\ 0,&\text{otherwise}\end{cases}$ (1)

##  III Approach

This section will discuss our proposed approach for identifying binary-source
matching pairs across programming languages. The overall workflow is shown in
Figure 1. The input to GraphBinMatch consists of two files, a source file and
a binary file written in different programming languages. The first step is to
compile the source file and decompile the binary file using the respective
language-specific front-ends and tools, to produce Intermediate
Representations (IR) that are language-independent. Next, we create graphs
capturing the programs’ control, data, and call flow. We treat these graphs as
heterogeneous graphs to better model the different types of nodes and edges.
An edge in the graphs represents the relationships between two nodes. These
heterogeneous graphs are inputs to our Graph Binary Matching Similarity Neural
Network (GraphBinMatch).

Figure 1:  The overview of our proposed approach.

###  III-A Intermediate Representation

As mentioned, the first step in our proposed approach is to convert the files
from the source language and binary to an intermediate representation.
Intermediate representation (IR) is an intermediate form that modern compilers
use to represent programs. IR provides a more straightforward abstraction. It
allows multiple stages of transformation and analysis in the compiler to
generate the target code more efficiently. Lowering programs to intermediate
representation is a common compiler technique to simplify and optimize code.
In GraphBinMatch, we first convert input files to LLVM IR. Using LLVM IR, our
approach can represent input files in a language-independent format, allowing
for easier comparison of code written in different programming languages.

We use two front-ends, JLang 111https://polyglot-compiler.github.io/JLang and
Clang 222https://clang.llvm.org, to convert Java and C++ programs to LLVM IR,
respectively. JLang supports Java up to version 7, while Clang-5.0 converts
C++ programs to LLVM IR. It is worth mentioning that different versions of
LLVM can produce slightly different IRs, so using the same version of Clang as
the one being used inherently by JLang helps to have more similarities between
Java and C++ programs.

Our proposed approach uses RetDec333 https://github.com/avast/retdec to
generate LLVM IR from binary executables.RetDec is an open-source machine-code
decompiler that can generate LLVM IR from binary executables. It supports
various architectures, including x86, ARM, MIPS, and PowerPC. RetDec uses
instruction parsing, data-flow analysis, and control-flow reconstruction
techniques to reverse-engineer the binary code into LLVM IR.

###  III-B Graph Generation

While there exist various approaches [9, 10, 11] to represent LLVM IR for deep
learning models, recently, it has been shown that presenting programs as
graphs can help deep learning models to learn the characteristics of programs
more effectively [12, 13, 14]. Following the recent success in presenting
programs as graphs, we also create graphs using LLVM IR files. In particular,
we use ProGraML [14] to generate a graph for each of the LLVM IR files in our
dataset. ProGraML extracts information from LLVM IR and constructs a graph
consisting of different types of nodes (i.e., instruction, variable and
constant) and edges (i.e., control flow, data flow, and call flow). These
graphs capture programs’ structural and semantic information and can be used
as inputs to machine learning models for various program analysis tasks,
including code similarity detection. These graphs must be encoded and passed
to a graph neural network designed to learn the similarities among matching
pairs and dissimilarities among non-matching pairs.

###  III-C Node Feature Embedding

To generate node embeddings, we split the process into two parts:
preprocessing of the source code and processing within the model itself.
During source file preprocessing, we create a feature vector for each node
using the full_text or text of the node’s attributes in the graph generated by
ProGraML. The full_text attribute represents the complete LLVM-IR instruction
for the node, whereas the text attribute only contains the corresponding
instruction type. For instance, in the instruction %16 = load i32 i32 %15
align 8, means the integer pointer %15 is loaded and stored in temporary
variable %16. We can only obtain the instruction type from the text attribute.
However, using the full_text attribute, we can determine that the load
instruction is responsible for loading an integer pointer. This additional
information can be used to better train the embedding layer and improve the
model’s accuracy.

We discovered that not all nodes have the full_text attribute during the
preprocessing process, as some nodes only represent compiler configurations
that only have text section. To address this issue, we use the text attribute
as a fallback option when the full_text attribute is unavailable.

The ProGraML paper itself uses text attribute of the nodes as the feature of
the nodes; however, later in the experimental result section, we will see that
using the full_text attribute of the nodes improves the prediction of the
GraphBinMatch. Moreover, we use the position property provided by ProGraML as
the edge feature. The position property in ProGraML contains the edge position
information. For instance, for a valid LLVM-IR instruction such as %result =
add i32 %1, %2, ProGraML generates an edge corresponding to %1 and an edge
corresponding to %2. In this example, the position of the first edge is 0, and
the position of the second edge is 1.

Finally, we use the tokenizer to tokenize those LLVM-IR instructions to create
the final node features, which we then add to the graph. Tokenizer is also
able to map each token to a corresponding integer number. Therefore we would
have a sequence of integer numbers representing an LLVM-IR instruction for a
node. This sequence of integer numbers is considered as the feature of the
node. In the conversion process, we convert all LLVM-IR variables, such as
$12, to a special token named [VAR]. By utilizing the tokenizer and carefully
selecting the truncation and padding lengths, we ensure that our feature
vectors are informative and can be effectively used in subsequent modeling
steps.

LLVM-IR instructions have varying lengths; therefore, the feature set of each
node in our graph will have its own length. To solve this problem and make
sure that all nodes have the same length for their features, We use the
average length of all nodes’ feature vectors rounded up to the nearest power
of 2 as the final intercept length. For example, if the average length of all
LLVM-IR instructions in the dataset is 50 after tokenization, the final
truncation length is 64. All feature vectors with a length of 64 will be
truncated, and all feature vectors with a length less than 64 will be padded
with [PAD] token.

Figure 2:  Structure of Graph Binary Matching Similarity Neural Network
(GraphBinMatch).

###  III-D Graph Binary Matching Similarity Neural Network

Once the preprocessing is finished, we will pass the graphs to our Graph
Binary Matching Similarity Neural Network (GraphBinMatch) for further
processing. GraphBinMatch is built upon SimGNN [15], but we have made several
modifications to tailor it for heterogeneous graph similarity tasks, which
will be discussed in the next sections.

The architecture of GraphBinMatch can be seen in Figure 2. To train
GraphBinMatch, we create data points consisting of three items: Source File A,
Binary File B, and Label. We use an embedding layer as the first layer of
GraphBinMatch. This layer processes the feature vector of each node and tries
to embed the nodes by learning the embedding space so that similar nodes would
have similar embedding. The embedding layer increases the dimensionality of
the entire feature vector to two dimensions. We utilize the max operation to
reduce the two-dimensional feature vector to a single dimension. This one-
dimensional feature vector serves as input to the graph convolution layer.

In the following subsections, we will provide a detailed explanation of each
component of GraphBinMatch.

####  III-D1 Heterogeneous Convolution

GraphBinMatch is designed to take in the graph representation of two files and
predict whether they match. The Convolution layer is constructed to support
the heterogeneous graph using the HeteroConv wrapper from the pytorch-
geometric library. As previously discussed, our Heterogeneous Graph
representation has three types of relationships. This layer includes three
separated GATv2Conv[16] layers to model each one of the relationships. The
outputs of the GATv2Conv layers are stacked together, and then the element-
wise maximum values are computed to have a latent representation of the nodes.
After each GATv2Conv, we include additional LayerNorm to stabilize training
and prevent overfitting.

####  III-D2 Attention

In GraphBinMatch, we incorporate an attention layer similar to the one
introduced in [15]. The attention layer operates by taking node embeddings
from the previous layer and passing them through an attention mechanism. We
use a global graph embedding vector $c\in\mathbb{R}^{D}$ where $D$ is the same
dimension as the nodes’ embedding dimension. $c$ is created by averaging node
embeddings passed through a non-linear transformation. This global embedding
vector $c$ contains the overall structure and information of the graph.

To calculate the attention for a given node $n_{i}$, we compute the inner
product of $c$ and the latent representation of $n_{i}$. The intuition behind
this approach is that nodes that are more similar to the overall context of
the graph should receive higher attention weights. Finally, the graph-level
embedding is created by computing the weighted sum of all nodes. Here, the
nodes’ weights refer to the nodes’ attention values.

####  III-D3 Fully Connected Layer

Once the graph-level embeddings on the two files are computed, the two vectors
are concatenated and transposed to be fed to the fully connected layer to have
the final prediction. In our study, we use two fully connected layers. After
the first fully connected layer, a normalization layer is also applied to
stabilize the learning process. Additionally, we introduce an extra dropout
layer before the last linear layer to increase nonlinearity and regularization
in the model.

In the next section, we evaluate GraphBinMatch and compare its results with
the state-of-the-art approach.

##  IV Experimental Setup

In this section, we evaluate GraphBinMatch and present the results and address
four research questions.

###  IV-A Tasks and Research Questions

We evaluate GraphBinMatch on cross-language and single-language tasks. For
each one of these tasks, we use a specific dataset. We define the research
questions as follows

  * •

RQ1: Can graph-based representation and GNNs outperform transformer-based
models in cross-language binary source code matching problems?

  * •

RQ2: Does GraphBinMatch provide consistent results when applied in a single-
language context with different optimization levels?

  * •

RQ3: How is the performance of GraphBinMatch across different compilers?

  * •

RQ4: Does GraphBinMatch perform well in terms of source-to-source matching?

###  IV-B Dataset Statistic

Cross Language Code Matching. To evaluate GraphBinMatch for the cross-language
binary-source matching task, we use the CLCDSA dataset [17], which consists of
source code files collected from two programming competition websites: AtCoder
and Google CodeJam. These programming competition websites feature multiple
tasks, and the dataset contains source code as solutions to the tasks in
various programming languages. We have selected c, c++, and java as the
languages for our study to assess the effectiveness of our model in learning
binary-source code similarities across different programming languages.

To ensure that our dataset has a balanced distribution of positive and
negative samples, we consider valid solutions to the same task as matching
pairs and valid solutions to different tasks as non-matching pairs. We discard
any file that is not compilable. Following the baseline paper, we adopt the
same train, validation, and test split ratio, which is a ratio of 6:2:2 to
split the dataset.

As mentioned, in this study, we utilize JLang444https://github.com/polyglot-
compiler/JLang and clang-5.0 as compilers for all java source code files.
JLang is an open-source compiler front-end that compiles java source code into
the corresponding LLVM-IR. This compiler is used to generate all corresponding
LLVM-IR expressions for Java files. To convert LLVM-IR to binary executable
files, Clang-5.0 is used. Throughout the experiments, 0z is set as the default
optimization level of the compiler unless the optimization level is explicitly
mentioned. To convert all binary executables to their LLVM-IR equivalent, we
use an open-source RetDec decompiler.

TABLE I: Dataset Statistics | Languages | # Sources | # LLVM-IR | # Binary Files | # Decompiled LLVM—IR
---|---|---|---|---|---
| C | 15605 | 13929 | 14370 | 13929
CLCDSA | C++ | 16676 | 15375 | 15766 | 15589
| Java | 19836 | 15124 | 17072 | 15124
POJ-104 | C++ | 52000 | 38598 | 38598 | 37909

Same Language Code Matching For the task of detecting matching within the same
programming language, we use the POJ-104 dataset [18]
555https://drive.google.com/uc?id=0B2i-vWnOu7MxVlJwQXN6eVNONUU. This dataset
comprises C++ solutions submitted by 500 students for 104 different
programming problems from an online judge system (OJ) that serves an
educational purpose. We compile the C++ source code files into LLVM-IR and
binary executable using different optimization levels of clang and gcc. To
decompile the binary executable to its corresponding LLVM-IR representation,
we utilized RetDec similarly for all the binary executables.

TableI shows the statistics of the two datasets.

###  IV-C Baselines

As discussed, We evaluate the performance of GraphBinMatch for two different
matching tasks: binary-source matching and source-source matching. To assess
the effectiveness of GraphBinMatch, we compare it against BinPro[3],
B2SFinder[7], and XLIR for binary-source matching.

BinPro is a tool that aims to tackle the challenge of identifying similarities
between source and binary code even when the compiler or optimization level
used is unknown. To this end, BinPro employs machine learning techniques to
compute the best code properties for determining binary-to-source code
similarity. These code properties are then extracted and computed using static
analysis tools to match binary and source codes with a bipartite matching
algorithm.

B2SFinder detects binary code clones by inferring seven traceable features in
binary and source code. It employs a weighted feature-matching algorithm
capable of handling different features and calculating the weights of code
feature instances based on their specificity and frequency of occurrence.

XLIR is a transformer-based neural network model which is currently state-of-
the-art for binary-source code matching. XLIR, as its name suggest, also uses
LLVM IR. To embed the tokens in LLVM IR, XLIR leverages a pre-trained BERT
model. The model first pre-trains the neural network using a large external
LLVM-IR corpus with masked language modeling (MLM)[19] as the pre-processing
step. This step is aimed at learning meaningful representations of the LLVM-IR
tokens. Once the tokens are embedded, XLIR maps them into a common space, and
the LLVM-IR representations are learned jointly using a ternary loss function.
This approach allows XLIR to match binary source code across different
programming languages.

For source-source matching, in addition to XLIR, we also compare the results
against LICAA[20]. LICCA works on the source code and extracts semantic and
syntactic characteristics of programs to identify matching pairs.

###  IV-D Experiment Setup

GraphBinMatch is built using Pytorch-Geometric666https://pytorch-
geometric.readthedocs.io, a powerful library for developing deep learning
models for graphs. For optimizing the learning parameters of GraphBinMatch,
Adam [21] Optimizer is used with a learning rate of $6.6e^{-5}$, and Binary
Cross Entropy is used as the loss function. We use GATv2[16] as the graph
convolution layer as discussed earlier. The hyper-parameters of GraphBinMatch
are tuned using RayTune777https://docs.ray.io/en/latest/tune/index.html. The
HuggingFace tokenizer888https://huggingface.co/docs/transformers/index is used
to tokenize the LLVM-IR instructions which serve as nodes’ features in our
graph representation.

GraphBinMatch comprises a PyTorch Embedding layer with a dimension of 128 to
embed the tokens, five GATv2 graph convolution layers with a dimension of 256,
and a HuggingFace GPT tokenizer with a max number of 2048 vocabularies. In the
GraphBinMatch model, we use LeakyReLU as our activation function, except the
last linear layer is followed by a Sigmoid function. We train GraphBinMatch
using four a100 NVIDIA GPUs with 80GB VRAM and Intel Xeon 6140 CPU with 128GB
RAM.

###  IV-E Evaluation Metrics

Parameter | Prediction | Actual
---|---|---
True Positive(TP) | Matching | Matching
True Negative(TN) | Non-matching | Non-matching
False Positive(FP) | Matching | Non-matching
False Negative(FN) | Non-matching | Matching
TABLE II:

In the realm of code matching detection, precision (P), recall (R), and
F1-scores (F1) are commonly used to evaluate the performance and accuracy of
the models. These three criteria are derived from four measures: true positive
(TP), true negative (TN), false positive (FP), and false negative (FN). The
definitions of these measures can be found in TableII.

Precision is often used to describe the accuracy of a model’s positive
prediction, that is, the accuracy for pairs identified as matching. It is
defined as the proportion of true matching pairs out of all the matching pairs
predicted by the model, as shown in Equation 2.

$P=\frac{TP}{TP+FP}$ (2)

Recall is defined as the percentage of matching pairs in the dataset that the
model correctly predicts as matching pairs, which is the case described by
Equation 3.

$R=\frac{TP}{TP+FN}$ (3)

F1-Score is commonly used to evaluate the performance of models. F1-Score is
defined as the harmonic mean of the precision and recall values, which is the
case described by Equation 3

$F1=\frac{2PR}{P+R}$ (4)

##  V Experimental Results

In this section, we address the research questions.

####  V-1 RQ1: Can graph-based representation and GNNs outperform transformer-
based models in cross-language binary source code matching problem?

TABLE III: Performance of cross-language binary-mating task (Threshold at
0.5).

| C/C++ binary code with Java source code | Java binary code with C/C++ source code
---|---|---
| Precision | Recall | F1 | Precision | Recall | F1
BinPro | - | - | - | 0.36 | 0.37 | 0.36
B2SFinder | - | - | - | 0.35 | 0.41 | 0.38
XLIR(LSTM) | 0.62 | 0.53 | 0.57 | 0.55 | 0.51 | 0.53
XLIR(Transformer) | 0.73 | 0.59 | 0.65 | 0.68 | 0.55 | 0.61
GraphBinMatch | 0.75 | 0.73 | 0.74 | 0.75 | 0.78 | 0.77
GraphBinMatch(Tokenizer) | 0.76 | 0.82 | 0.79 | 0.76 | 0.77 | 0.77

*Because of the limitations of BinPro and B2Sfinder in handling Java source code, we cannot provide test results for Java as source code *In this table and the following ones, the results of the other tools are quoted from the baseline paper.

To answer the question of RQ1, we trained our model using the CLCDSA dataset.
We evaluated the performance of GraphBinMatch in the binary-source matching
task by comparing it against the aforementioned baselines, as shown in
TableIII. We used LLVM-IR from binary C/C++ programs and java source code as
GraphBinMatch’s input in our experiments. The results show the effectiveness
of GraphBinMatch with the precision, recall, and F1 scores achieving 0.76,
0.82, and 0.79, respectively. This represents over 20% improvement compared to
the baseline paper. To further strengthen the robustness of our results, we
conducted an additional experiment using LLVM-IR from Java binary and C/C++
source code. This yielded satisfactory results, with precision, recall, and F1
scores of 0.76, 0.77, and 0.77, respectively, which exceeded the baseline by
25%.

Table III reveals a performance gap between using binary Java source code and
binary C/C++ code for the same task and dataset. This gap may be attributed to
certain differences between the LLVM-IR obtained by decompiling and the one
obtained from source code, as GraphBinMatch struggles to comprehend. The
decompiled LLVM-IR is not always identical to the source code, and we
attribute this difference to two primary factors. Firstly, the decompiled code
may not always have the exact data type or the correct shape of arrays for
array types. Secondly, the decompilation process often involves speculation
and assumptions, resulting in variations in the control flow generated by
decompiling binaries. Combining these factors within the binary file causes
differences in the LLVM-IR.

####  V-2 RQ2: Does GraphBinMatch provide consistent results when applied in a
single-language context with different optimization levels?

TABLE IV: Performace of single language binary matching task (Threshold at 0.5). | Precision | Recall | F1
---|---|---|---
BinPro | 0.38 | 0.42 | 0.40
B2SFinder | 0.43 | 0.46 | 0.44
XLIR(LSTM) | 0.67 | 0.72 | 0.44
XLIR(Transformer) | 0.85 | 0.86 | 0.85
GraphBinMatch | 0.88 | 0.86 | 0.87
TABLE V: Same language binary matching result from different optimization level | clang-10.0 | gcc-9.4
---|---|---
| Precision | Recall | F1 | Precision | Recall | F1
O0 | 0.88 | 0.86 | 0.87 | 0.87 | 0.86 | 0.87
O1 | 0.87 | 0.88 | 0.88 | 0.89 | 0.85 | 0.85
O2 | 0.86 | 0.82 | 0.84 | 0.87 | 0.83 | 0.85
O3 | 0.86 | 0.83 | 0.85 | 0.84 | 0.81 | 0.83
Oz | 0.90 | 0.85 | 0.87 | 0.87 | 0.87 | 0.87

We can confidently answer yes to this research question. For this study, we
used a different dataset than CLCDSA due to insufficient data for the same
language. As shown in Table I, CLCDSA has a maximum of only 15589 C++ source
codes available, whereas the POJ-105 dataset provides 37909 source codes. This
replacement of the dataset provides 1.5 times more code. POJ-105 is also the
dataset that has been used in the baseline paper as well. Table IV reveals
that GraphBinMatch outperforms the baseline paper regarding precision, recall,
and F1 scores, with scores of 0.88, 0.86, and 0.87, respectively, indicating
that GraphBinMatch is more proficient at detecting binary-source matching of
the same language. This table shows that the transformer-based model (XLIR)
can perform quite well as the LLVM-IR from the same language since these IRs
show more similarities. Despite the good XLIR(Transformer) scores on a single
language, GraphBinMatch still outperforms XLIR(Transformer).

To verify the robustness of GraphBinMatch in different optimization scenarios,
we evaluated its performance using clang on the same dataset but with four
different optimization levels (O0, O1, O2, O3, Oz). TableV shows that
GraphBinMatch achieves consistent performance across different optimization
levels. This indicates that the model’s performance is not dependent on a
specific compiler or optimization level and can provide reliable results under
varying conditions.

By examining the performance of GraphBinMatch with different optimization
levels of the same compiler, we can obtain some insights regarding RQ2. We
suspect that higher optimization levels would result in more aggressive
optimizations by the compiler, such as control flow tuning. These
optimizations would provide the decompiler with additional assumptions and
speculations, resulting in an increased difference between LLVM-IR from both
the source code and the binary executable. As shown in Table V, we observe
that the precision, recall, and F1 scores used to measure model performance
gradually decrease as the optimization level increases. This suggests that
more aggressive optimizations can slightly affect the model’s performance in
code matching detection.

####  V-3 RQ3: How is the performance of GraphBinMatch across different
compilers?

GraphBinMatch showed consistent performance across different optimization
levels of the same compiler; in this subsection, we want to investigate
further to see whether it could also provide similar performance across
different compilers. This is an important consideration for real-world
applications where the compiler used to generate a binary executable may be
unknown. To test this, we used clang to generate LLVM-IR from the source code,
but gcc to generate the binary executable of the POJ-104s dataset compared to
RQ2. We kept the same settings as in RQ2 to convert the binary executable to
the corresponding LLVM-IR using RetDec. Table V presents the performance of
GraphBinMatch when generating binary executable using gcc. The results show
that GraphBinMatch performs relatively the same when using different
compilers.

We suspect the better performance figures of gcc than clang because the used
decompilers tend to provide more information when compiling the C++ code
generated by gcc. This is supported by our analysis, which shows that the
average size of LLVM-IR generated by binary executables compiled with clang is
about $10,769.9$ bytes, while the average size of those compiled with gcc is
about $18,525.2$ bytes. This means at the decompilation stage, the size of gcc
compiled binary files is approximately 70% larger than those compiled with a
clang. Such a significant difference in size will likely affect
GraphBinMatch’s ability to accurately detect binary matching.

####  V-4 RQ4: Does GraphBinMatch perform well in terms of source-to-source
matching?

TABLE VI: Cross language source matching result | GraphBinMatch | XLIR (LSTM) | XLIR (Transformer)
---|---|---|---
| Precision | Recall | F1 | Precision | Recall | F1 | Precision | Recall | F1
C vs Java | 0.77 | 0.80 | 0.78 | 0.62 | 0.51 | 0.56 | 0.75 | 0.55 | 0.63
C++ vs Java | 0.76 | 0.82 | 0.79 | 0.65 | 0.53 | 0.58 | 0.77 | 0.57 | 0.66
C/C++ vs Java | 0.81 | 0.73 | 0.78 | - | - | - | - | - | -

In the source-source matching task, we evaluate the performance of
GraphBinMatch using the CLCDSA dataset and compare it with the baseline paper.
The experimental setup was the same as in RQ1, except that we used the LLVM-IR
generated by JLang as input to GraphBinMatch. We test three language
combinations: C/C++ vs. Java, C vs. Java, and C++ vs. Java. Table VI shows
that GraphBinMatch outperformed the baseline paper by about 20% regarding
precision, recall, and F1 scores. GraphBinMatch can also effectively detect
source code matching across different programming languages.

###  V-A Varying Threshold

Figure 3:  [Higher is better] Varying the threshold results in different
scores for precision, recall, and f1.

In the previous subsection, we mentioned that the threshold for GraphBinMatch
was set to 0.5. We experimented with varying thresholds to investigate the
effect of different thresholds on precision, recall, and F1 scores. Figure 3
shows the different scores that can be achieved by varying the threshold.
Based on our findings, a threshold value of 0.2 would provide a slightly
better F1 score. However, we also observed that using this threshold would
significantly decrease accuracy to as high as 7%, making it impractical to use
for optimal F1 score to find the best threshold. As a result, we chose to use
a threshold value of 0.5, which we considered to be a more reasonable default
threshold for our study. A smaller threshold yields higher recall since
GraphBinMatch will predict all pairs as matching pairs. On the other hand, a
larger threshold will result in higher precision, as GraphBinMatch predicts
all pairs as non-matching pairs. Depending on the use case, a user of
GraphBinMatch can manually set the threshold or let GraphBinMatch decide the
best threshold based on the given metric (i.e., precision, recall, F1).

##  VI Discussions

In this section, we discuss some challenges that can affect the performance of
GraphBinMatch.

TABLE VII: Statistics for the number of nodes in test set Type | Mean | Median
---|---|---
True Positive | 1506 | 864
False Positive | 2133 | 1303
True Negative | 2573 | 1680
False Negative | 2293 | 1289

###  VI-A Investigating why GraphBinMatch may fail

Our experiments revealed that our model occasionally misidentifies pairs of
matching code fragments. After reviewing the mispredicted samples
individually, we found that most false positives occur because of a large gap
in the sizes of the LLVM-IR fragments. We calculated and analyzed the number
of nodes in the test set graphs and obtained Table VII. The table shows that
the difference in the mean and the median number of nodes predicted by our
model is much larger for the false positive set than for the true positive
set. The median difference in the number of nodes between the two sets is
nearly 50%.

After conducting an in-depth analysis, we found two main reasons for these
false positives. The first reason is that the gap between LLVM-IR is larger
than the tolerance of GraphBinMatch. For example, some code snippets may use
sorting methods provided by the standard library, while others may implement
their own sorting methods internally. GraphBinMatch may not effectively
recognize that the method calls of the standard library are equivalent to the
sorting methods the authors themselves have implemented in their code.
Additionally, the template mechanism in C++ can impact GraphBinMatch since
many of the C++ standard libraries are published as templates. This means that
templates are also compiled as a part of LLVM-IR, which causes struggles for
GraphBinMatch to recognize that the compiled template code is equivalent to
standard library calls in Java.

The second scenario involves language differences between Java and C++ and
different usage habits among their respective user communities, which can
result in significant discrepancies in the LLVM-IR even when both are
converted to compile as LLVM-IR. These discrepancies are rooted in the varying
habits of different programming language users. For example, Figure 4 displays
a matching pair that, despite their similarity, generate IR graphs with vastly
different sizes: the Java-generated IR graph has 330 nodes and 660 edges,
whereas the C++-generated IR graph has only 65 nodes and 115 edges. Such
discrepancies can cause challenges for GraphBinMatch to recognize matching
pairs, as the model may not account for the impact of language usage habits on
the IR generation process, leading to incorrect results.

###  VI-B Extending GraphBinMatch to other programming languages

This study introduced a novel approach to detecting cross-language binary-code
matching using graph neural networks (GNNs). A crucial component of our
approach is using LLVM IR to measure the similarities between two programs
written in different languages. By leveraging LLVM IR, we can capture high-
level information about the code independent of the underlying programming
languages.

While our approach is designed to be cross-language, it relies on the
availability of compiler front-ends. One must use the corresponding compiler
front-end to extend our approach to support additional programming languages
to produce LLVM IR. Once the IR is generated, our approach remains the same.
Our method is flexible enough to support any programming language compiled
into LLVM IR.

(a) Samples from Java

(b) Samples from c++

Figure 4: An example of false negative case

###  VI-C How tokenizer and different token embedding influence the result

TABLE VIII: Performance of different LLVM-IR embedding techniques for same-language binary matching and cross-language binary matching | Cpp vs Cpp | Cpp/C vs Java
---|---|---
| Precision | Recall | F1 | Precision | Recall | F1
text | 0.86 | 0.83 | 0.85 | 0.75 | 0.73 | 0.74
full_text | 0.89 | 0.87 | 0.88 | 0.84 | 0.75 | 0.79

In this section, we conduct an experimental study using the CLCDSA dataset
with the same settings and preprocessing methods as in RQ1. Our objective is
to investigate the impact of various token embedding techniques and tokenizers
on the performance of GraphBinMatch. Specifically, we aim to explore the
effects of different embedding methods and tokenization schemes on the ability
of GraphBinMatch to match binary and source code pairs across multiple
programming languages or the same languages. By examining these factors, we
hope to better understand how to optimize the performance of GraphBinMatch and
improve its ability to detect code clones in diverse language pairs.

First, we aim to evaluate the impact of using the full_text property versus
full_text for the source-binary matching task. In the approach section of our
paper, we mentioned that using the full_text property provided by ProGraML
could lead to better performance than using full_text alone. As shown in Table
VIII, we observe that using the full_text attribute improves the performance
for both cross-language binary-source matching tasks and same-language binary-
source matching tasks. Notably, for cross-language binary-source code tasks,
using the full_text attribute provides more significant improvement than
binary-source code matching tasks written in the same language. We believe
this result is because by exposing more information to the model, we can
better bridge the understanding gap of the model on cross-language tasks.

##  VII Related Works

Code similarity detection has recently gained considerable attention with the
advent of research tools and machine learning models. These advancements
provide new opportunities for research in this field. In code similarity
detection, the similarity of source code is generally classified into four
levels, as outlined in [13]:

  * •

Type I: This is also called Exact Clone. The source code can be identical,
with only the indentation, comments, and code layout modified.

  * •

Type II: This is also called Parameterized clone. The source code’s structure
and syntactic are similar except for some variable names, method names, and
data types modified in addition to those mentioned in Type I.

  * •

Type III: Compared to Type II, Type III code clone involves modification of
statements, but the functional similarity is maintained.

  * •

Type IV: The structure between two code fragments is syntactically and
structurally different, but both code fragments perform similar behavior for
the same input.

Research on code similarity detection is broadly divided into two research
directions: algorithm-based and machine learning-based. Each of these two
different directions will be described in detail below:

###  VII-A Algorithm based Approaches

The algorithm-based code clone detection is based on lexical or semantic
analysis, so most do not have a good detection result for Type IV code clones,
or even when Type III gaps are too large or too frequent. Most of the
algorithms are only applicable to Type I, Type II, and part of Type III code
clones. Also, their results for cross-language code clone detection are often
unsatisfactory.

Research projects like CCFinderSW[22] and SourcerCC[23] use a token-based
approach to detect code clones. Each of these tools uses its own
implementation of a lexical analyzer to convert the source code into a token
stream which serves as a basis for analysis and similarity score measurement
using different algorithms. However, because of the lack of lexical
information abstraction, it is difficult for these algorithms to obtain and
understand the inherent semantics.

Semantic analysis-based code clone detection tools try to solve this problem.
DECKARD[24] proposes a tree-based code clone detection scheme: it innovatively
uses feature vectors to describe the structure of the syntax tree and clusters
the clones by the Euclidean distance of the feature vectors.

Traditional algorithm-based code clone detection methods are often difficult
to transfer to cross-language clone detection, resulting in very few studies
addressing this problem. Even if the relevant studies propose corresponding
solutions, they are limited by various restrictions and cannot address real-
world requirements. Two of the most representative studies are LICCA[25] and
CLCMiner[26]. LICCA detects code clones by attempting to convert different
languages into uniform expressions, which can only cover cases where two
pieces of code have a similar structure and syntactic elements. CLCMiner uses
an NLP approach to view the source code but relies on the modification records
of the source code.

###  VII-B Machine Learning Approaches

With the advancements in machine learning and graph neural networks, new ideas
have emerged to solve the code clone detection problem. With the introduction
of various code cloning datasets, it has become possible to use machine
learning to solve such problems. Like CLCDSA[17] and BigCloneBench[27], they
both contain code clones with Type IV similarity. Many recent studies have
tried to replace traditional algorithms with machine learning models to
achieve better accuracy and gain the ability to compare across different
languages.

CLDH[28] first proposed a hash method to detect whether two pieces of code in
the same language are clones. Their model accepts raw code fragments as input,
encodes the abstract syntax tree using specific rules, and transforms it into
a vector representation of the source code using an LSTM network. However,
their encoding approach focuses more on the structure of the AST without
considering other semantic information like node type.

In addition to tree-based methods, methods like CCLearner[29] and C4[30] use
token-based code clone detection: One of the first studies to use tokens as
input to a code clone detection model is CCLearner. It classifies tokens into
eight categories, calculates the similarity score for each category
separately, and then uses the similarity of vectors to calculate the
similarity between code fragments. This study concluded that more similarities
in feature vectors imply a higher probability that a code pair is a code
clone. This study only captures token and partial syntax level information but
not the structure of the code. Their paper stated that CCLearner does not have
good detection performance for Type IV/Type III clones due to this reason.

Another token-based research is C4[30]. Their study used a pre-trained Bert
model called codebert[31] to embed the model’s inputs. Since CodeBERT supports
encoding multiple languages, C4 also supports cross-language code clone
detection. Their study uses raw source code as input and first use CodeBERT to
encode the raw source code to obtain a feature vector, and then their model
learns and classifies the feature vector to obtain the final similarity score.
They also implemented Contrastive Learning to increase the usage of the
dataset. However, C4 only supports encoding the first 512 tokens because of
the limitation of CodeBERT, affecting the final applicability of C4.

The current academic focus is mainly on source code clone detection, but Gui
et al.’s XLIR has shifted the attention back to the problem of cross-language
binary source code matching. It is common for software applications to be
written in different programming languages to meet various requirements and
computing platforms. Therefore, detecting binary source code clones across
multiple programming languages can be beneficial in practical scenarios. For
instance, when vulnerable binary code is detected, it becomes necessary to
retrieve relevant source code fragments of all possible programming languages
written for better vulnerability assessment. We use XLIR as the baseline
paper; more details on its methodology and performance are provided in the V
section.

##  VIII Conclusion and Future Works

This paper introduced GraphBinMatch, a novel cross-language binary-source
matching model that uses LLVM IRs and Heterogeneous graphs to learn the
similarities. The model takes LLVM IR as input and can handle three types of
code-matching detection tasks: cross-language binary matching detection,
single-language binary matching detection, and cross-language source matching
detection. It should be noted that GraphBinMatch is not limited to these
specific languages. It can support any programming language with a compiler
front end to generate LLVM IR.

Experimental results show that GraphBinMatch is effective and outperforms all
three state-of-the-art tools. Specifically, our approach outperforms these
tools regarding precision, recall, and F1 score, which indicates that it
excels in identifying cross-language code matches.

In future work, we aim to extend GraphBinMatch to more programming languages,
incorporating additional compiler front-ends to generate LLVM IR for these
languages. Moreover, since our approach is data-driven, we are collecting more
source code files to increase the size of the dataset, which will believe will
improve the prediction of GraphBinMatch. By incorporating these improvements,
we believe that GraphBinMatch will become a more powerful tool for code-
matching detection and benefit software developers in maintaining and
improving their code base.

## References

  * [1] R. T. Yarlagadda, “Approach to computer security via binary analytics,” _INTERNATIONAL JOURNAL OF INNOVATIONS IN ENGINEERING RESEARCH AND TECHNOLOGY [IJIERT]_ , 2020.
  * [2] H. Yang, M. Fritzsche, C. Bartz, and C. Meinel, “Bmxnet: An open-source binary neural network implementation based on mxnet,” in _Proceedings of the 25th ACM international conference on Multimedia_ , 2017, pp. 1209–1212.
  * [3] D. Miyani, Z. Huang, and D. Lie, “Binpro: A tool for binary source code provenance,” _arXiv preprint arXiv:1711.00830_ , 2017.
  * [4] A. Shahkar, “On matching binary to source code,” Ph.D. dissertation, Concordia University, 2016.
  * [5] G. Zhao and J. Huang, “Deepsim: deep learning code functional similarity,” in _Proceedings of the 2018 26th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering_ , 2018, pp. 141–151.
  * [6] Z. Yu, R. Cao, Q. Tang, S. Nie, J. Huang, and S. Wu, “Order matters: Semantic-aware neural networks for binary code similarity detection,” in _Proceedings of the AAAI Conference on Artificial Intelligence_ , vol. 34, no. 01, 2020, pp. 1145–1152.
  * [7] Z. Yuan, M. Feng, F. Li, G. Ban, Y. Xiao, S. Wang, Q. Tang, H. Su, C. Yu, J. Xu _et al._ , “B2sfinder: Detecting open-source software reuse in cots software,” in _2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE)_. IEEE, 2019, pp. 1038–1049.
  * [8] Y. Gui, Y. Wan, H. Zhang, H. Huang, Y. Sui, G. Xu, Z. Shao, and H. Jin, “Cross-language binary-source code matching with intermediate representations,” in _2022 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER)_. Los Alamitos, CA, USA: IEEE Computer Society, mar 2022, pp. 601–612. [Online]. Available: https://doi.ieeecomputersociety.org/10.1109/SANER53432.2022.00077
  * [9] T. Ben-Nun, A. S. Jakobovits, and T. Hoefler, “Neural code comprehension: A learnable representation of code semantics,” _Advances in Neural Information Processing Systems_ , vol. 31, 2018.
  * [10] S. VenkataKeerthy, R. Aggarwal, S. Jain, M. S. Desarkar, R. Upadrasta, and Y. Srikant, “Ir2vec: Llvm ir based scalable program embeddings,” _ACM Transactions on Architecture and Code Optimization (TACO)_ , vol. 17, no. 4, pp. 1–27, 2020.
  * [11] Y. Sui, X. Cheng, G. Zhang, and H. Wang, “Flow2vec: Value-flow-based precise code embedding,” _Proceedings of the ACM on Programming Languages_ , vol. 4, no. OOPSLA, pp. 1–27, 2020.
  * [12] M. Allamanis, “Graph neural networks in program analysis,” in _Graph Neural Networks: Foundations, Frontiers, and Applications_. Springer, 2022, pp. 483–497.
  * [13] M. Allamanis, M. Brockschmidt, and M. Khademi, “Learning to represent programs with graphs,” _arXiv preprint arXiv:1711.00740_ , 2017.
  * [14] C. Cummins, Z. V. Fisches, T. Ben-Nun, T. Hoefler, and H. Leather, “Programl: Graph-based deep learning for program optimization and analysis,” _arXiv preprint arXiv:2003.10536_ , 2020.
  * [15] Y. Bai, H. Ding, S. Bian, T. Chen, Y. Sun, and W. Wang, “Simgnn: A neural network approach to fast graph similarity computation,” in _Proceedings of the Twelfth ACM International Conference on Web Search and Data Mining_ , 2019, pp. 384–392.
  * [16] S. Brody, U. Alon, and E. Yahav, “How attentive are graph attention networks?” in _International Conference on Learning Representations_ , 2022\. [Online]. Available: https://openreview.net/forum?id=F72ximsx7C1
  * [17] K. W. Nafi, T. S. Kar, B. Roy, C. K. Roy, and K. A. Schneider, “Clcdsa: cross language code clone detection using syntactical features and api documentation,” in _2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE)_. IEEE, 2019, pp. 1026–1037.
  * [18] L. Mou, G. Li, L. Zhang, T. Wang, and Z. Jin, “Convolutional neural networks over tree structures for programming language processing,” in _Proceedings of the AAAI conference on artificial intelligence_ , vol. 30, no. 1, 2016.
  * [19] K. Sinha, R. Jia, D. Hupkes, J. Pineau, A. Williams, and D. Kiela, “Masked language modeling and the distributional hypothesis: Order word matters pre-training for little,” _arXiv preprint arXiv:2104.06644_ , 2021.
  * [20] T. Vislavski, G. Rakić, N. Cardozo, and Z. Budimac, “Licca: A tool for cross-language clone detection,” in _2018 IEEE 25th International Conference on Software Analysis, Evolution and Reengineering (SANER)_. IEEE, 2018, pp. 512–516.
  * [21] D. P. Kingma and J. Ba, “Adam: A method for stochastic optimization,” _arXiv preprint arXiv:1412.6980_ , 2014.
  * [22] Y. Semura, N. Yoshida, E. Choi, and K. Inoue, “Ccfindersw: Clone detection tool with flexible multilingual tokenization,” in _2017 24th Asia-Pacific Software Engineering Conference (APSEC)_ , 2017, pp. 654–659.
  * [23] H. Sajnani, V. Saini, J. Svajlenko, C. K. Roy, and C. V. Lopes, “Sourcerercc: Scaling code clone detection to big-code,” in _Proceedings of the 38th International Conference on Software Engineering_ , ser. ICSE ’16. New York, NY, USA: Association for Computing Machinery, 2016, p. 1157–1168. [Online]. Available: https://doi.org/10.1145/2884781.2884877
  * [24] L. Jiang, G. Misherghi, Z. Su, and S. Glondu, “Deckard: Scalable and accurate tree-based detection of code clones,” in _29th International Conference on Software Engineering (ICSE’07)_ , 2007, pp. 96–105.
  * [25] T. Vislavski, G. Rakić, N. Cardozo, and Z. Budimac, “Licca: A tool for cross-language clone detection,” in _2018 IEEE 25th International Conference on Software Analysis, Evolution and Reengineering (SANER)_ , 2018, pp. 512–516.
  * [26] X. Cheng, Z. Peng, L. Jiang, H. Zhong, H. Yu, and J. Zhao, “Clcminer: detecting cross-language clones without intermediates,” _IEICE TRANSACTIONS on Information and Systems_ , vol. 100, no. 2, pp. 273–284, 2017\.
  * [27] J. Svajlenko and C. K. Roy, “Bigclonebench,” in _Code Clone Analysis_. Springer, 2021, pp. 93–105.
  * [28] H. Wei and M. Li, “Supervised deep features for software functional clone detection by exploiting lexical and syntactical information in source code,” in _Proceedings of the Twenty-Sixth International Joint Conference on Artificial Intelligence, IJCAI-17_ , 2017, pp. 3034–3040. [Online]. Available: https://doi.org/10.24963/ijcai.2017/423
  * [29] L. Li, H. Feng, W. Zhuang, N. Meng, and B. Ryder, “Cclearner: A deep learning-based clone detection approach,” in _2017 IEEE International Conference on Software Maintenance and Evolution (ICSME)_. IEEE, 2017, pp. 249–260.
  * [30] C. Tao, Q. Zhan, X. Hu, and X. Xia, “C4: Contrastive cross-language code clone detection,” in _2022 IEEE/ACM 30th International Conference on Program Comprehension (ICPC)_ , 2022, pp. 413–424.
  * [31] Z. Feng, D. Guo, D. Tang, N. Duan, X. Feng, M. Gong, L. Shou, B. Qin, T. Liu, D. Jiang _et al._ , “Codebert: A pre-trained model for programming and natural languages,” _arXiv preprint arXiv:2002.08155_ , 2020.


# Density-polarity coupling in confined active polar films:
asters, spirals, and biphasic orientational phases

Mathieu Dedenon1,2 Claire A. Dessalles1 Pau Guillamat3 Aurélien Roux1 Karsten
Kruse1,2<EMAIL_ADDRESS>Carles Blanch-Mercader4 carles.blanch-
<EMAIL_ADDRESS>1Department of Biochemistry, University of Geneva, 1211
Geneva, Switzerland  2Department of Theoretical Physics, University of Geneva,
1211 Geneva, Switzerland  3Institute for Bioengineering of Catalonia,
Barcelona Institute of Science and Technology, Barcelona, Spain
4PhysicoChimie Curie, Institut Curie, PSL Research University, CNRS UMR168,
Paris, France

###### Abstract

Topological defects in active polar fluids can organise spontaneous flows and
influence macroscopic density patterns. Both of them play, for example, an
important role during animal development. Yet the influence of density on
active flows is poorly understood. Motivated by experiments on cell monolayers
confined to discs, we study the coupling between density and polar order for a
compressible active polar fluid in presence of a $+1$ topological defect. As
in the experiments, we find a density-controlled spiral-to-aster transition.
In addition, biphasic orientational phases emerge as a generic outcome of such
coupling. Our results highlight the importance of density gradients as a
potential mechanism for controlling flow and orientational patterns in
biological systems.

Active matter is composed of individual constituents able to extract energy
from their local environment to produce mechanical work [1, 2]. This feature
gives rise to collective phenomena that play an important role in many
biological systems, such as the emergence of polar flocking, motility-induced
phase separation or spontaneous flows [1, 2]. For instance, spontaneous flows
generated by gradients of active stress have been observed in various systems,
including cytoskeleton assays [3, 4, 5], or multicellular ensembles [6, 7, 8,
9, 10]. All these systems can organize into out-of-equilibrium phases with
domains featuring orientational order. This order can locally be disrupted by
disclinations, often called topological defects, which are associated with
rotational flow patterns [11, 2, 12].

Both, theoretical and experimental studies have demonstrated that the
interplay between topological defects and active processes concentrates
mechanical stress, leading to the formation of density gradients [13, 8, 7,
14, 15, 16, 17, 18]. Reciprocally, cell density variations influence
orientational order [19, 20]. Given the growing recognition of topological
defects as organizing centers during morphogenesis [8, 7, 21, 17],
understanding how density gradients and orientational order interact is
essential.

Figure 1: Density-driven transition of a confined polar tissue. (a) Phase-
contrast image of a confined monolayer of C2C12 myoblasts, showing a spiral
(left) or an aster (right) polar state. Scale bar is $50~{}\mu$m. Modified
from [20]. (b) Radial cell density profile for spirals and asters. Data
extracted from [17]. (c) Schematic representing a polar tissue confined to a
disc of radius $R$, described as a 2D compressible polar fluid with velocity
$\bm{v}$, polarity $\bm{p}$ with radial angle $\psi$, and density $n$. (d)
Schematic representing the effect of the Density-Polarity Coupling (DPC), see
Eq. (2).

A density-controlled transition between different $+1$ topological defects was
observed in monolayers of polarized cells confined to a disc [17]. At low cell
density, spontaneous rotational flows emerged in a spiral multicellular
arrangement. Whereas for increasing cell density, a transition occurred to an
aster arrangement without rotational flows, Fig. 1a. Steeper cell density
gradients were found for asters compared to spirals, Fig. 1b. In the
hydrodynamic description of an incompressible active polar fluid, an aster-to-
spiral transition arises from the competition between the active stress and
orientational elasticity [22]. The transition corresponds to a spontaneous
flow instability [23, 24, 25, 26], where density does not appear explicitly as
a control parameter.

In this Letter, we study a coupling between density gradients and
orientational order, in the case of $+1$ topological defects in confined
active polar fluids, Fig. 1d. In spreading cell monolayers, this Density-
Polarity Coupling (DPC) expresses a tendency of cells to polarize away from
high density regions [27, 28, 29]. First, we identify conditions for a
density-controlled spiral-to-aster transition. Second, we show that biphasic
orientational phases are a generic feature of compressible polar fluids.
Finally, we discuss the relevance of DPC for monolayers of polarized cells.

To describe a two-dimensional compressible active polar fluid, we use active
gel theory [22, 30]. The system is characterised by velocity
$\bm{v}(\bm{r},t)$, polarity $\bm{p}(\bm{r},t)$ and particle density
$n=n_{0}\bar{n}(\bm{r},t)$ fields, where $n_{0}$ is the preferred particle
density, Fig. 1c.

The equilibrium physics is captured by an effective free energy
$\mathcal{F}=\int_{A}\mathrm{d}A\,f$ with free-energy density

$f=\frac{B}{2}\left(1-\bar{n}\right)^{2}+\frac{G}{2}|\bm{\nabla}\bar{n}|^{2}+\frac{K}{2}|\bm{\nabla}\bm{p}|^{2}+\frac{\chi}{2}\bm{p}^{2}+f_{\rm
DPC}.$ (1)

The first two terms penalize density variations with elastic coefficients
$B,G>0$. The second two terms tend to suppress polarity variations with
elastic coefficients $K,\chi>0$. Thus, we favour a disordered phase in the
bulk. We use the one-constant approximation [31] for simplicity and leave the
general case for future studies.

The last term, $f_{\rm DPC}$, accounts for the coupling between density and
polarity. The lowest order term in powers of $(\bm{p},\bm{\nabla}\bar{n})$
with polar symmetry reads

$f_{\rm DPC}=J_{\rm p}n_{0}(\bm{p}\cdot\bm{\nabla})\bar{n},$ (2)

which is related to a density-dependent spontaneous splay term of the Frank
free energy [32, 31, 29]. Previous works identified a linear instability of an
ordered state associated with this coupling [33, 34, 35, 36, 37]. Negative
(positive) values of the coupling coefficient $J_{\rm p}$ favor
(anti-)alignment of polarity to density gradients, Fig. 1d. From now on, we
use $J_{\rm p}n_{0}\equiv j_{\rm p}$ as control parameter.

The evolution of the fields $\bar{n}$, $\bm{v}$ and $\bm{p}$ is determined by
the continuity equation, the polarity dynamics and the local force balance:

$\displaystyle\partial_{t}\bar{n}$ $\displaystyle=$
$\displaystyle-\partial_{\beta}(\bar{n}v_{\beta})$ (3a) $\displaystyle
D_{t}p_{\alpha}$ $\displaystyle=$
$\displaystyle\frac{h_{\alpha}}{\gamma}-\nu\left(v_{\alpha\beta}-\frac{1}{2}v_{\gamma\gamma}\delta_{\alpha\beta}\right)p_{\beta}$
(3b) $\displaystyle 0$ $\displaystyle=$
$\displaystyle\partial_{\beta}(\sigma_{\alpha\beta}^{\rm
e}+\sigma_{\alpha\beta}^{\rm d}),$ (3c)

where $\mathbf{h}=-\delta\mathcal{F}/\delta\bm{p}$ is the molecular field,
$v_{\alpha\beta}=(\partial_{\alpha}v_{\beta}+\partial_{\beta}v_{\alpha})/2$,
and
$\omega_{\alpha\beta}=(\partial_{\alpha}v_{\beta}-\partial_{\beta}v_{\alpha})/2$
are the symmetric and anti-symmetric parts of the velocity gradient tensor,
and
$D_{t}p_{\alpha}=\partial_{t}p_{\alpha}+v_{\beta}\partial_{\beta}p_{\alpha}+\omega_{\alpha\beta}p_{\beta}$
is the co-rotational derivative. The stress is decomposed into the Ericksen
and the deviatoric components that read

$\displaystyle\sigma_{\alpha\beta}^{\rm e}$ $\displaystyle=$
$\displaystyle-P\delta_{\alpha\beta}-(G\partial_{\beta}\bar{n}+j_{\rm
p}p_{\beta})\partial_{\alpha}\bar{n}-K\partial_{\alpha}p_{\gamma}\partial_{\beta}p_{\gamma}$
(4a) $\displaystyle\sigma_{\alpha\beta}^{\rm d}$ $\displaystyle=$
$\displaystyle
2\eta\left(v_{\alpha\beta}-\frac{1}{2}v_{\gamma\gamma}\delta_{\alpha\beta}\right)$
$\displaystyle+$
$\displaystyle\frac{\nu}{2}(p_{\alpha}h_{\beta}+p_{\beta}h_{\alpha}-p_{\gamma}h_{\gamma}\delta_{\alpha\beta})+\frac{1}{2}(p_{\alpha}h_{\beta}-p_{\beta}h_{\alpha})$
$\displaystyle-$ $\displaystyle\frac{1}{2}\zeta_{0}\Delta\mu
p_{\gamma}p_{\gamma}\delta_{\alpha\beta}-\zeta\Delta\mu\left(p_{\alpha}p_{\beta}-\frac{1}{2}p_{\gamma}p_{\gamma}\delta_{\alpha\beta}\right)$

with the pressure $P=\mu\bar{n}-f$, the chemical potential
$\mu=\delta\mathcal{F}/\delta\bar{n}$ and $\Delta\mu$ is the chemical
potential difference extracted from fuel consumption. The phenomenological
parameters are the rotational viscosity $\gamma$, the flow alignment
coefficient $\nu$, the shear viscosity $\eta$, and the active isotropic
(anisotropic) coefficient $\zeta_{0}$ ($\zeta$).

As in the experimental system of Ref. [17], we consider an active fluid
confined to a disc of radius $R$, Fig. 1c. Using polar coordinates
$(r,\theta)$, the polarity field is decomposed into the polar order $S$ and
the tilt angle $\psi$ with respect to the radial direction, so that
$\bm{p}=S\cos\psi\,\mathbf{e}_{r}+S\sin\psi\,\mathbf{e}_{\theta}$, where
$\mathbf{e}_{r}$ and $\mathbf{e}_{\theta}$ are the unit polar vectors. In
addition we assume rotational invariance, $\partial_{\theta}=0$. Because our
theoretical description is achiral, without loss of generality, we restrict
the range of angles to $\psi=[0,\pi]$. Using the convention that outward
polarity corresponds to $\psi<\pi/2$, one can classify the different $+1$
topological defects into out-aster $\psi=0$, out-spiral $0<\psi<\pi/2$, vortex
$\psi=\pi/2$, in-spiral $\pi/2<\psi<\pi$ and in-aster $\psi=\pi$.

The evolution equations for the fields $\bar{n}$, $S$, $\psi$, $v_{r}$ and
$v_{\theta}$ are detailed in Supplementary Material (SM) [38]. Motivated by
the experiments in [17], spatial boundary conditions at $r=R$ are set to $S=1$
(boundary-induced order), $\partial_{r}\psi=0$ (free orientation), $v_{r}=0$
(absence of particle flux), and $\sigma_{\theta r}=0$ (absence of shear
stress). At equilibrium, the last boundary condition at $r=R$ is obtained from
the minimization of the free energy (1), which yields
$\partial_{r}\bar{n}=-j_{\rm p}\cos\psi/G$. We assume that this condition also
holds out-of-equilibrium. At $r=0$, regularity of the solution imposes that
$S=\partial_{r}\psi=\partial_{r}\bar{n}=v_{r}=v_{\theta}=0$.

Parameters are non-dimensionalized by using disc radius $R$ as length scale,
Frank constant $K$ as energy scale and rotational viscosity $\gamma$ to obtain
a time scale $\gamma R^{2}/K$. In the following, $B=12$, $G=2$, $\eta=2$,
$\nu=-1.5$ are fixed, and $\chi$, $j_{\rm p}$, $\zeta\Delta\mu$,
$\zeta_{0}\Delta\mu$ are varied. In numerics, the initial polarity is oriented
outwards (i.e. $\psi(r,t=0)<\pi/2$), and the total particle density
$\int_{A}\mathrm{d}A\,n/A$ is set to $n_{0}$ to avoid any pre-stress in the
uniform configuration. For more details on the numerical scheme and initial
conditions, see SM [38].

Figure 2: Spiral-to-aster transition induced by DPC. (a) Density plot of the
peripheral angle $\psi_{R}=\psi(R)$ at steady-state, as a function of
anisotropic activity ($\zeta\Delta\mu$) and DPC ($j_{\rm p}$) coefficients.
Blue curve: threshold $|j_{\rm p}|=|j_{\rm p}^{*}|$ from Eq. (6). (b-e) Radial
profiles of azimuthal velocity $v_{\theta}(r)$ (b), angle $\psi(r)$ (c),
density variation $\delta\bar{n}=\bar{n}(r)-1$ (d) and polar order $S(r)$ (e),
for $\zeta\Delta\mu=2$ and $j_{\rm p}$ varies as indicated in legend (e) and
black arrow (a,c). Gray line in (c): Leslie angle $\psi_{L}$. Parameters are
$\chi=4$ and $\zeta_{0}\Delta\mu=0$.

First, we consider the case of vanishing activity
$\zeta\Delta\mu=\zeta_{0}\Delta\mu=0$. In this case, the equilibrium states
are in- and out- asters, Fig. 2a, which have the same total energy and are
selected through spontaneous symmetry breaking. The corresponding density
gradients have opposite signs, see SM [38].

Next, in the case of vanishing DPC $j_{\rm p}=0$, spontaneous flows occur when
$\zeta\Delta\mu>0$, Fig. 2. Specifically, in- and out-asters transition to
rotating spirals when anisotropic activity switches from contractile
$\zeta\Delta\mu<0$ to extensile $\zeta\Delta\mu>0$, Fig. 2a-c. Unlike in past
works [22, 23], here the instability threshold vanishes because of the absence
of boundary anchoring. Spirals feature counter-rotating flows with a vanishing
net torque because forces are internal, see Fig. 2b. Their steady-state
orientation angle $\psi(r)=\psi_{L}$ satisfies the relation
$\nu\cos(2\psi_{L})=1$ [39], where $\psi_{L}$ is the Leslie angle, see Fig.
2c. Gradients of density are sustained by active processes in both spirals and
asters, with their direction set by
$\bar{n}^{\prime}\sim-(\zeta\cos(2\psi)+\zeta_{0})\Delta\mu$ for uniform
$\psi$ [40], see Fig. 2d for an extensile spiral.

Based on the above results, when $j_{\rm p}\neq 0$ and $\zeta\Delta\mu>0$, we
expect competition between DPC, promoting radial configurations, and the
active anisotropic stress driving the polarity towards the Leslie angle.
Solving numerically our hydrodynamic equations (3), a spiral-to-aster
transition is found at a threshold value of $j_{\rm p}$, Fig. 2a and c. As
$|j_{\rm p}|$ increases near the threshold value, density gradients become
steeper and the angle $\psi$ approaches zero as for the out-aster state thanks
to DPC, Fig. 2c,d. In contrast, the polar order parameter remains
approximately independent of $j_{\rm p}$, Fig. 2e. Importantly, this
transition now occurs at a finite threshold of activity, Fig. 2a.

To further understand this competition, we analysed the linear stability of an
out-aster to perturbations in the angle $\psi$, see SM [38]. Neglecting
gradients of orientation Fig. 2c, the linear dynamics for the angle
perturbation $\delta\psi$ reduces to

$\partial_{t}\delta\psi\propto\left\\{j_{\rm p}\bar{n}_{\rm
a}^{\prime}+\frac{2\zeta\Delta\mu\gamma(1-\nu)S_{\rm a}^{3}}{4\eta+\gamma
S_{\rm a}^{2}(\nu-1)^{2}}\right\\}\delta\psi$ (5)

where $S_{\rm a}(r)$ and $\bar{n}_{\rm a}(r)$ are, respectively, the steady-
state polar order and reduced density for an out-aster. Assuming that the
instability originates from the boundary, we replace these profiles by their
boundary values $S_{\rm a}=1$ and $\bar{n}_{\rm a}^{\prime}=-j_{\rm p}/G$ in
Eq. (5) and obtain the analytical threshold

$|j_{\rm p}^{*}|=\sqrt{\frac{2\zeta\Delta\mu
G\gamma(1-\nu)}{4\eta+\gamma(1-\nu)^{2}}}.$ (6)

This threshold suggests that an out-aster is linearly unstable for
$\zeta\Delta\mu(1-\nu)>0$ and an intermediate range of the DPC coefficient
$|j_{\rm p}|<|j_{\rm p}^{*}|$. Expression (6) is in qualitative agreement with
numerics, Fig. 2a. In conclusion, DPC can suppress the spontaneous flow
transition and stabilise asters in active polar fluids.

Let us reconsider the equilibrium case. There, linear stability analysis shows
that DPC alone can destabilize a uniform ordered state [33, 34, 35, 36].
Indeed equilibration of density fluctuations leads to an effective Frank free-
energy with a renormalized splay constant $K_{\rm s}=K-j_{\rm p}^{2}/B$,
whereas the bend constant remains unchanged $K_{\rm b}=K$, see SM [38]. For
$K_{\rm s}<0$, that is above the threshold value $|j_{\rm
p}^{\dagger}|=\sqrt{KB}$, splay distortions are favoured. In our system, the
threshold for this instability $j_{\rm p}^{\dagger}$ is modified by activity
and boundary conditions. The instability is associated with a finite
wavelength, which can generate biphasic orientational phases in the context of
$+1$ topological defects that we analyze in the following.

Beyond the spontaneous splay instability, biphasic asters emerge where in- and
out-aster states coexist, Fig. 3a. This state is characterised by a non-
monotonic density profile, favouring non-uniform orientations due to DPC, Fig.
3a, and a sharp interface with strong orientation gradients
($R|\bm{\nabla}\psi|\gg 1$). Because the positive bend constant $K_{\rm b}=K$
prevents large gradients of $\psi$, the polar order $S$ needs to be
sufficiently small to stabilize the interface, Fig. 3a, inset. This can be
achieved in the disordered limit $\sqrt{K/\chi}\ll R$, such that polar order
is localized at the disc periphery, see Fig. 3a.

Below the spontaneous splay instability, double spirals can be found. They are
characterised by a gradual gradient of orientation ($R|\bm{\nabla}\psi|\sim
1$), Fig. 3b. This gradient results from a competition between active
alignment and DPC, modulated by the local amplitude of polar order $S$.
Indeed, if anisotropic activity dominates over DPC at the periphery ($S\sim
1$), spirals are stabilised for $\zeta\Delta\mu>0$, Fig. 3b. Away from the
periphery, where order is weak ($S\ll 1$), DPC always dominates, favouring
out-asters for inward density gradients, Fig. 3b. Contrary to Fig. 2c,e where
polar order remains large near the center, locally attenuating the competition
between active alignment and DPC, here the disordered limit $\sqrt{K/\chi}\ll
R$ results in larger orientational gradients.

These states can be characterized by the peripheral angle $\psi_{R}=\psi(R)$
and the angle difference between the periphery and the center
$\Delta\psi=\psi(R)-\psi(0)$. Whereas Fig. 3d is apparently similar to Fig.
2a, the state diagram for the angle difference in Fig. 3e reveals biphasic
asters and double spirals with $\Delta\psi\neq 0$, SM [38]. The dependence on
activity of the spontaneous splay threshold can be understood from the non-
monotonicity of density profiles, as in Fig. 3a. Whereas density gradients
$\bar{n}^{\prime}(R)$ are set by DPC at the periphery, in the bulk, they scale
as $\bar{n}^{\prime}\sim-(\zeta+\zeta_{0})\Delta\mu$ when activity dominates.
Therefore, biphasic asters are favoured when $j_{\rm p}>0$ and
$(\zeta+\zeta_{0})\Delta\mu<0$ or vice-versa, in agreement with state $2$ in
Fig. 3e when $\zeta_{0}\Delta\mu=0$, or in Fig. 3g when
$\zeta_{0}\Delta\mu\neq 0$.

At low values of $|j_{\rm p}|$, double spirals can emerge, states $4$, $6$ and
$8$ in Fig. 3e,g. Whereas peripheral orientation remains outward when
$\zeta_{0}\Delta\mu=0$, Fig. 3e, large isotropic activity can induce inward
oriented states $7$ and $8$ in Fig. 3f,g. These states can no longer be
understood from peripheral angle dynamics alone. They appear when anisotropic
active stresses overcome DPC at the periphery, in combination with outward
(inward) bulk density gradients to promote inward orientation for $j_{\rm
p}>0$ ($j_{\rm p}<0$). Increasing $\zeta_{0}\Delta\mu$ to positive values
changes the direction of bulk density gradients, and reverses the central
angle from inwards to outwards through the sequence of states $8\rightarrow
6\rightarrow 4$ for $j_{\rm p}>0$, see Fig. 3c,g.

Figure 3: Orientational patterns induced by DPC. (a-b) Radial profiles of
angle (left), density variation (middle) and polar order (right), for biphasic
asters (a) and double spirals (b). Inset: polar order near disc center. (c)
Schematics of orientation states. (d-g) Steady-state density plots: peripheral
angle $\psi_{R}=\psi(R)$ (d,f) and angle difference between periphery and
center $\Delta\psi=\psi(R)-\psi(0)$ (e,g). Dashed lines in (d-g): $j_{\rm
p}=\pm\sqrt{KB}$. Black arrow in (g): double spiral to aster transition.
Parameters $\chi=81$, $\zeta_{0}\Delta\mu=0$ for (d,e), and
$\zeta\Delta\mu=20$ for (f,g).

In summary, a local coupling between polarity and density gradients can
account for the observed transition between rotating spirals and non-flowing
asters as cell density increases, Fig. 1. In addition, these results provide
an alternative interpretation of this transition, in terms of a transition
from a double spiral to an aster, black arrow in Fig. 3g. In this case, for
low densities, a double spiral with aster-like orientation $\psi\simeq 0$ in
the center is found, Fig. 3b,g. With increasing density, this inner phase
expands until it fills the entire disc and the angle becomes $\psi=0$. This
double-spiral state delays the relaxation of the peripheral angle towards
zero, which is consistent with experiments, see appendix.

The spiral-to-aster transition discussed above crucially relies on the choice
of the free energy term $f_{\rm DPC}$ (Eq. 2). Alternatively, it can be
written as $f_{\rm DPC}=-j_{\rm p}\bar{n}\bm{\nabla}\cdot\bm{p}$, which leads
to the equilibrium BC $\partial_{r}\bar{n}(R)=0$. In SM [38], we show that the
main results remain unchanged for different parameter values. One could also
consider a free energy of the form $\tilde{f}_{\rm DPC}=J_{\rm
p}(\bm{p}\cdot\bm{\nabla})n/n_{0}$ [33, 24, 41]. In this case, a density-
controlled spiral-to-aster transition occurs if $\zeta\Delta\mu$ decreases
with density. Then, other parameters like isotropic active stress also need to
depend on density to match the observed density profiles in Fig. 1b.
Therefore, Eq. 2 corresponds to a minimal extension of Ref. [20].

DPC not only provides an explanation for the dynamics of polar tissues on
discs, Fig. 1, but also proposes a mechanism for collective states found in
giant epithelial cell monolayers [28]. There, a radially spreading tissue
develops azimuthal flows in the central region, and density gradients become
non-monotonic. In our framework, this state resembles biphasic asters except
for an outward spiral orientation near the center in Ref. [28]. We expect this
difference to originate from a global polar order, which is able to sustain
bulk active stresses contrary to our disordered system. Validation of these
hypotheses requires a precise measurement of the cell polarity field and
complementary theoretical analysis.

To our knowledge, the above experimental works represent the first evidences
of DPC in cellular systems. To further investigate this coupling
experimentally, one could control density gradients using optogenetic tools
[42] and generate specific flow or polarity patterns. Although we have focused
on systems with polar symmetry, it is also interesting to consider couplings
between density gradients and other types of orientational order, like nematic
systems [43].

###### Acknowledgements.

We are grateful to Jean-François Joanny and Ram Adar for insightful
discussions, Ricard Alert for pointing out reference [28], and Ludovic
Dumoulin for help on numerical methods. The computations were performed at
University of Geneva on Baobab HPC cluster. C.A.D. acknowledges funding from
the EMBO fellowship ALTF 886-2022, and P.G. acknowledges support from the
Human Frontiers of Science Program (grant number LT-000793/2018-C).

*

## Appendix A

Here we compare the evolution of the peripheral angle $\psi_{R}$ between
experiment and theory. Experiments in Ref. [17] first show a spiral maintained
over one day, followed by a rapid transition to an aster, see Fig.A1b. In
theory, assuming uniform angle $\psi=\psi_{R}$ and transition controlled by
boundary effects, we obtain an expression for the angle

$\cos(2\psi_{R})=\frac{1}{\nu}\frac{1}{1-j^{2}}\left[1-\frac{j^{2}}{2}\left(\frac{4\eta}{\gamma}+\nu^{2}+1\right)\right],$
(7)

see SM [38]. The critical value $j_{\rm p}^{*}$ at which spiral-to-aster
transition occurs is given by Eq. (6). Comparison between experiments and Eq.
(7) shows agreement for $\eta/\gamma\ll 1$, see Fig.A1a. Previous quantitative
analysis [20, 40] suggests that $\eta/\gamma\sim 1$.

Figure A1: Experimental-theoretical comparison of peripheral angle evolution.
(a) Peripheral angle $\psi_{R}=\psi(R)$ as a function of the reduced density
$\hat{n}=n_{0}/n_{0}^{*}$ (black: experiment, blue: Eq. (7)) for different
values of $\eta/\gamma$ and $\nu=-1.01$. The value of $j=j_{\rm
p}/\sqrt{\zeta\Delta\mu G}$ is chosen such that the spiral-to-aster transition
occurs at $\hat{n}=1.48$. Experimental densities were linearly interpolated
between the initial value $n_{0}^{*}$ and the value at the transition. (b)
Peripheral angle $\psi_{R}=\psi(R)$ as a function of time (black: experiment,
green: numerics) for different values of active stresses
$\zeta/\Delta\mu=\zeta_{0}\Delta\mu$. The other parameters are $\nu=-1.01$,
$\eta/\gamma=2$, $\chi=81$, $\psi(t=0)=\psi_{L}$ and $j_{\rm
p}(t)=3.5(t/36~{}\text{h})$. Data extracted from [17].

In the main text, we showed the existence of double spirals, Fig. 3b. For high
values of activity coefficients $\zeta\Delta\mu$, $\zeta_{0}\Delta\mu$ and
increasing $j_{\rm p}>0$ (black arrow in Fig. 3g), spiral orientation is
maintained at the periphery while aster-like orientation develops in center.
Compared to uniform angle states, this delays the spiral-aster transition
time, see Fig. A1b. Thus, double spiral itself can also quantitatively
reproduce experimental data.

## References

  * Marchetti  _et al._ [2013] C. M. Marchetti, J. F. Joanny, S. Ramaswamy, T. B. Liverpool, J. Prost, M. Rao, and R. A. Simha, Hydrodynamics of soft active matter, Reviews of Modern Physics 85, 1143 (2013).
  * Shankar  _et al._ [2022] S. Shankar, A. Souslov, M. J. Bowick, M. C. Marchetti, and V. Vitelli, Topological active matter, Nature Reviews Physics 4, 380 (2022).
  * Nédélec  _et al._ [1997] F. J. Nédélec, T. Surrey, A. C. Maggs, and S. Leibler, Self-organization of microtubules and motors, Nature 389, 305 (1997).
  * Schaller  _et al._ [2010] V. Schaller, C. Weber, C. Semmrich, E. Frey, and A. R. Bausch, Polar patterns of driven filaments, Nature 467, 73 (2010).
  * Opathalage  _et al._ [2019] A. Opathalage, M. M. Norton, M. P. N. Juniper, B. Langeslay, S. A. Aghvami, S. Fraden, and Z. Dogic, Self-organized dynamics and the transition to turbulence of confined active nematics, Proceedings of the National Academy of Sciences 116, 4788 (2019).
  * Siegert and Weijer [1995] F. Siegert and C. J. Weijer, Spiral and concentric waves organize multicellular Dictyostelium mounds, Current Biology 5, 937 (1995).
  * Kawaguchi  _et al._ [2017] K. Kawaguchi, R. Kageyama, and M. Sano, Topological defects control collective dynamics in neural progenitor cell cultures, Nature 545, 327 (2017).
  * Saw  _et al._ [2017] T. B. Saw, A. Doostmohammadi, V. Nier, L. Kocgozlu, S. Thampi, Y. Toyama, P. Marcq, C. T. Lim, J. M. Yeomans, and B. Ladoux, Topological defects in epithelia govern cell death and extrusion, Nature 544, 212 (2017).
  * Duclos  _et al._ [2018] G. Duclos, C. Blanch-Mercader, V. Yashunsky, G. Salbreux, J.-F. Joanny, J. Prost, and P. Silberzan, Spontaneous shear flow in confined cellular nematics, Nature Physics 14, 728 (2018).
  * Streichan  _et al._ [2018] S. J. Streichan, M. F. Lefebvre, N. Noll, E. F. Wieschaus, and B. I. Shraiman, Global morphogenetic flow is accurately predicted by the spatial distribution of myosin motors, eLife 7, e27454 (2018).
  * Doostmohammadi  _et al._ [2018] A. Doostmohammadi, J. Ignés-Mullol, J. M. Yeomans, and F. Sagués, Active nematics, Nature Communications 9, 3246 (2018).
  * Leclech and Barakat [2023] C. Leclech and A. I. Barakat, Physiological ramifications of constrained collective cell migration, BioEssays 45, 2300017 (2023).
  * Giomi  _et al._ [2014] L. Giomi, M. J. Bowick, P. Mishra, R. Sknepnek, and M. Cristina Marchetti, Defect dynamics in active nematics, Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences 372, 20130365 (2014).
  * Turiv  _et al._ [2020] T. Turiv, J. Krieger, G. Babakhanova, H. Yu, S. V. Shiyanovskii, Q.-H. Wei, M.-H. Kim, and O. D. Lavrentovich, Topology control of human fibroblast cells monolayer by liquid crystal elastomer, Science Advances 6, eaaz6485 (2020).
  * Endresen  _et al._ [2021] K. D. Endresen, M. Kim, M. Pittman, Y. Chen, and F. Serra, Topological defects of integer charge in cell monolayers, Soft Matter 17, 5878 (2021).
  * Brézin  _et al._ [2022] L. Brézin, T. Risler, and J.-F. Joanny, Spontaneous flow created by active topological defects, The European Physical Journal E 45, 30 (2022).
  * Guillamat  _et al._ [2022] P. Guillamat, C. Blanch-Mercader, G. Pernollet, K. Kruse, and A. Roux, Integer topological defects organize stresses driving tissue morphogenesis, Nature Materials 21, 588 (2022).
  * Kaiyrbekov  _et al._ [2023] K. Kaiyrbekov, K. Endresen, K. Sullivan, Z. Zheng, Y. Chen, F. Serra, and B. A. Camley, Migration and division in cell monolayers on substrates with topological defects, Proceedings of the National Academy of Sciences 120, e2301197120 (2023).
  * Duclos  _et al._ [2014] G. Duclos, S. Garcia, H. G. Yevick, and P. Silberzan, Perfect nematic order in confined monolayers of spindle-shaped cells, Soft Matter 10, 2346 (2014).
  * Blanch-Mercader  _et al._ [2021a] C. Blanch-Mercader, P. Guillamat, A. Roux, and K. Kruse, Quantifying Material Properties of Cell Monolayers by Analyzing Integer Topological Defects, Physical Review Letters 126, 028101 (2021a).
  * Maroudas-Sacks  _et al._ [2021] Y. Maroudas-Sacks, L. Garion, L. Shani-Zerbib, A. Livshits, E. Braun, and K. Keren, Topological defects in the nematic order of actin fibres as organization centres of Hydra morphogenesis, Nature Physics 17, 251 (2021).
  * Kruse  _et al._ [2004] K. Kruse, J. F. Joanny, F. Jülicher, J. Prost, and K. Sekimoto, Asters, Vortices, and Rotating Spirals in Active Gels of Polar Filaments, Physical Review Letters 92, 078101 (2004).
  * Voituriez  _et al._ [2005] R. Voituriez, J. F. Joanny, and J. Prost, Spontaneous flow transition in active polar gels, Europhysics Letters (EPL) 70, 404 (2005).
  * Giomi  _et al._ [2008] L. Giomi, C. M. Marchetti, and T. B. Liverpool, Complex Spontaneous Flows and Concentration Banding in Active Polar Films, Physical Review Letters 101, 198101 (2008).
  * Fürthauer  _et al._ [2012] S. Fürthauer, M. Neef, S. W. Grill, K. Kruse, and F. Jülicher, The Taylor–Couette motor: spontaneous flows of active polar fluids between two coaxial cylinders, New Journal of Physics 14, 023001 (2012).
  * Shendruk  _et al._ [2017] T. N. Shendruk, A. Doostmohammadi, K. Thijssen, and J. M. Yeomans, Dancing disclinations in confined active nematics, Soft Matter 13, 3853 (2017).
  * Streichan  _et al._ [2014] S. J. Streichan, C. R. Hoerner, T. Schneidt, D. Holzer, and L. Hufnagel, Spatial constraints control cell proliferation in tissues, Proceedings of the National Academy of Sciences 111, 5586 (2014).
  * Heinrich  _et al._ [2020] M. A. Heinrich, R. Alert, J. M. LaChance, T. J. Zajdel, A. Košmrlj, and D. J. Cohen, Size-dependent patterns of cell proliferation and migration in freely-expanding epithelia, eLife 9, e58945 (2020).
  * Alert and Trepat [2020] R. Alert and X. Trepat, Physical Models of Collective Cell Migration, Annual Review of Condensed Matter Physics 11, 77 (2020).
  * Jülicher  _et al._ [2018] F. Jülicher, S. W. Grill, and G. Salbreux, Hydrodynamic theory of active matter, Reports on Progress in Physics 81, 076601 (2018).
  * Gennes and Prost [1993] P.-G. d. Gennes and J. Prost,  _The physics of liquid crystals_ , 2nd ed., International series of monographs on physics No. 83 (Clarendon Press, Oxford, 1993).
  * Frank [1958] F. C. Frank, I. Liquid crystals. On the theory of liquid crystals, Discussions of the Faraday Society 25, 19 (1958).
  * Kung  _et al._ [2006] W. Kung, C. M. Marchetti, and K. Saunders, Hydrodynamics of polar liquid crystals, Physical Review E 73, 031708 (2006).
  * Voituriez  _et al._ [2006] R. Voituriez, J. F. Joanny, and J. Prost, Generic Phase Diagram of Active Polar Films, Physical Review Letters 96, 028102 (2006).
  * Adar and Joanny [2022] R. M. Adar and J.-F. Joanny, Active-gel theory for multicellular migration of polar cells in the extra-cellular matrix, New Journal of Physics 24, 073001 (2022).
  * Adar and Joanny [2021] R. M. Adar and J.-F. Joanny, Permeation Instabilities in Active Polar Gels, Physical Review Letters 127, 188001 (2021).
  * Ibrahimi and Merkel [2023] M. Ibrahimi and M. Merkel, Deforming polar active matter in a scalar field gradient, New Journal of Physics 25, 013022 (2023).
  * sup [2023] Supplementary material, URL_will_be_inserted_by_publisher (2023).
  * Leslie [1968] F. M. Leslie, Some constitutive equations for liquid crystals, Archive for Rational Mechanics and Analysis 28, 265 (1968).
  * Blanch-Mercader  _et al._ [2021b] C. Blanch-Mercader, P. Guillamat, A. Roux, and K. Kruse, Integer topological defects of cell monolayers: Mechanics and flows, Physical Review E 103, 012405 (2021b).
  * Notbohm  _et al._ [2016] J. Notbohm, S. Banerjee, K. J. Utuje, B. Gweon, H. Jang, Y. Park, J. Shin, J. P. Butler, J. J. Fredberg, and M. C. Marchetti, Cellular Contraction and Polarization Drive Collective Cellular Motion, Biophysical Journal 110, 2729 (2016).
  * Gligorovski  _et al._ [2023] V. Gligorovski, A. Sadeghi, and S. J. Rahi, Multidimensional characterization of inducible promoters and a highly light-sensitive LOV-transcription factor, Nature Communications 14, 3810 (2023).
  * Wang  _et al._ [2023] Z. Wang, C. M. Marchetti, and F. Brauns, Patterning of morphogenetic anisotropy fields, Proceedings of the National Academy of Sciences 120, e2220167120 (2023).