# STraceBERT: Source Code Retrieval using Semantic Application Traces

Claudio Spiess  0009-0000-5932-7022<EMAIL_ADDRESS>University of
California at DavisUSA

###### Abstract.

Software reverse engineering is an essential task in software engineering and
security, but it can be a challenging process, especially for adversarial
artifacts. To address this challenge, we present STraceBERT, a novel approach
that utilizes a Java dynamic analysis tool to record calls to core Java
libraries, and pretrain a BERT-style model on the recorded application traces
for effective method source code retrieval from a candidate set. Our
experiments demonstrate the effectiveness of STraceBERT in retrieving the
source code compared to existing approaches. Our proposed approach offers a
promising solution to the problem of code retrieval in software reverse
engineering and opens up new avenues for further research in this area.

tracing, reverse engineering, neural information retrieval

##  1\. Introduction

Software reverse engineering is a critical task in the field of software
engineering and security. It involves the reconstruction of the source code
from the compiled binary code to understand the functionality and
vulnerabilities of the software. The task becomes more challenging in an
adversarial setting, where the binary may be intentionally constructed to
hinder analysis. A common example is ransomware, which can be expected to be
obfuscated and invoke antianalysis techniques. A reverse engineer wants to
understand how the malware works, so they can discover weaknesses,
capabilities, and vulnerabilities used. Yet, understanding behavior from
millions of assembler instructions is untenable, and practitioners have
developed decompiler tools such as Ghidra for native binaries, or Procyon,
CFR, and Fernflower for Java bytecode. However, these tools are sensitive to
obfuscation techniques, and the usefulness of their output is limited in many
such cases.

We hypothesize that while any binary can obfuscate their control flow,
variable names, etc, they cannot hide their system calls without a rootkit.
Such system calls can be recorded on Unix systems with the strace command. We
hypothesize that a complex enough sequence of system calls can be used to
retrieve the source code that initiated them, using an embedding model and
vector database to retrieve the most similar known sequence of calls with
source code. Due to the challenge of aligning method boundaries and source
code with system call sequences, we adapt this problem to the Java ecosystem.
We utilize a Java dynamic analysis tool Jackal, that instruments bytecode on
the fly and records events such as method calls, exits, and field
modifications.

We draw an analogy between system calls and calls into Java core libraries
i.e. java.*. Using Jackal, we trace the test suites of a set of open source
Java projects, record their true source code, train a BERT-style model on the
sequences of Java calls, embed all sequences, and then evaluate the similarity
of proposed source code candidates for a holdout set. Through our experiments,
we demonstrate the effectiveness of our proposed model in retrieving the
source code compared to existing baselines.

##  2\. Background and Related Work

We searched for similar works applying dynamic analysis for obtaining or
augmenting source code, decompilation with ML augmentation, and clone
detection. There is a line of work that uses ML methods to improve decompiled
code (Al-Kaswan et al., 2023; Lacomis et al., 2019). Another line of work
looks at binary clone detection & binary diffs (Duan et al., 2020; Farhadi et
al., 2014; Hu et al., 2018). Finally, a line of work looks at embedding binary
code (Ding et al., 2019). We found only some work (Pei et al., 2021) which
uses dynamic analysis techniques in a similar fashion as this work.

##  3\. Approach

As our approach is novel, we begin by constructing the Java Trace Dataset
(JTD) (Claudio Spiess, 2023) as outlined in Figure 1. The JTD consists of Java
application traces obtained from a variety of open-source projects. Each trace
in the JTD dataset is a sequence of method invocations that represents the
execution of a test case. To produce this dataset, we gather a list of top
Java projects on GitHub by number of stars, and trace 30 projects’ test suites
and record call sequences, call sequences _with_ call boundaries, source code,
and various metadata such as maximum call graph depth at a method level,
excluding the test case method itself. A high-quality test suite is optimal
for constructing a candidate set for retrieval, but once constructed, binaries
being reverse engineered do _not_ require a test suite.

Figure 1. Overview of the STraceBERT approach.

We remove all duplicate call sequences to ensure there are no exact duplicate
call sequences between traces. We note that for each method, an average of 12
traces were recorded. For such cases, the call sequence and thus call sequence
with boundaries are unique, but the source code is the same. We then pick four
projects for which the traces act as the candidate set. We split the data into
three sets: candidates, for which traces of a particular method by fully-
qualified name (FQN) occur _at least once_ in candidate project traces, and
queries, which consists of traces for which the FQN was encountered _only_ in
non-candidate projects. As our test sets, we create the With Libraries set by
randomly sampling 10k traces from the candidate set without replacement, and
Without Libraries by randomly sampling 10k traces from the queries set. This
leaves us with a candidate set and two query sets for evaluation: one where we
assume the binary under examination uses common libraries such as Apache
Commons, and one that doesn’t. This provides an upper and lower bound on
expected performance.

For pre-training the STraceBERT models, we use all traces in the candidate
set, with or without associated source code as the training set. We use a
sample of 10k traces from the training set for validation. An example of a
call is -> java.lang.String.trim(): java.lang.String. We represent each call
signature by one unique token in our vocabulary, to maximize the number of
calls we can ingest in our model, and to reduce vocabulary size. For sequences
with call boundaries, method invocations and exits outside of the java.*
namespace are demarcated by the special tokens [CALL] and [EXIT] respectively.
We do not include the name of the called method to avoid data leakage, as the
method names would be obfuscated in practice.

Our model is an adapted BERT (Devlin et al., 2019) model with a custom
tokenizer designed for call sequences. We retain the default hyperparameters,
except the attention window size increase to 768, and due to compute
limitations, we decrease the following hyperparameters from the default by
33%: intermediate size of 2048, hidden size of 512, 8 attention heads, and 6
hidden layers. Hyperparameter optimization is left to future work. We first
pretrain the model on call sequences from the JTD, using standard Masked
Language Modeling (MLM), and default mask probability of 15%. We train for 400
epochs. Once the model is pretrained, it produces embeddings for each trace in
the corpus. These embeddings are used for source code retrieval.

##  4\. Evaluation and Results

Our goal is to retrieve candidate snippets of code for a reverse engineer. We
presume that presenting five examples to the reverse engineer will allow them
to better understand the method they are working with. To evaluate how useful
a retrieved snippet is, we measure code similarity between the query ground-
truth source code versus each retrieved candidate snippet. For this purpose,
all metrics are presented in the form of top@k, meaning the average maximum
similarity score between the ground-truth source code and the top $k$
retrieved candidates for all queries _e.g._ , top@5 would be the maximum
CodeBLEU (Ren et al., 2020) score of the first five candidates retrieved for
each query, averaged across all queries. We utilize the CodeBLEU code
similarity measure due to its high correlation with human scores of up to
$R^{2}=0.9548$. (Ren et al., 2020) For each trace in our evaluation sets With
Libraries & Without Libraries, we retrieve five nearest-neighbors from our
candidate set using FAISS (Johnson et al., 2019) and the trace embeddings from
our models. We then calculate and record the similarity metric.

Table 1. Retrieval performance in terms of average maximum CodeBLEU@k, With Libraries and Without Libraries. |  $+$ Libraries |  $-$ Libraries
---|---|---
Top@$k$ | @1 | @5 | @1 | @5
STraceBert | 75.09 | 90.88 | 21.72 | 28.99
$+$ Boundaries | 86.26 | 93.48 | 22.08 | 29.55
Random | 18.03 | 29.37 | 16.95 | 26.50
Codex | 29.85 | 38.39 | 22.08 | 31.45
BM25 | 37.57 | 61.11 | 17.70 | 23.44
CodeBERT | 98.71 | 98.77 | 31.75 | 33.57

We present our results in Table 1. As a reference, we provide a random
baseline where the candidates are picked randomly, BM25 (Robertson and Walker,
1994), and Codex (Chen et al., 2021). For Codex, we sample 100 queries from
each query set, and create an 8-shot prompt following (Nashid et al., 2023) by
finding the nearest neighbors of the trace query in the candidate set,
filtered to have less than 100 Java calls and less than 300 characters of
source code due to context window limitations. We also compare a strawman
retrieval using the CodeBERT (Feng et al., 2020) embedding of the source code.
Due to source code overlap but lack of _trace sequence_ overlap between With
Libraries and candidate set, retrieval via CodeBERT finds exact matches. Using
trace embeddings, we find for the average query _with_ call boundaries, the
first candidate has an average CodeBLEU value of 86.26 _vs._ 75.09 _without_
call boundaries. Performance differences decrease @5, with 93.48 _vs._ 90.88
respectively. Further analysis revealed that CodeBLEU values were not a result
of exact matches, suggesting similar code produces similar sequences of calls.
This presents strong evidence that trace embeddings can be used to find
similar code.

##  5\. Conclusion

In conclusion, the results of our experiments demonstrate the effectiveness of
the STraceBERT approach for the code retrieval task in software reverse
engineering. We find that embedding Java application traces using a BERT-style
model allows for effective source code retrieval, outperforming traditional
information retrieval approach BM25, and modern few-shot prompting of Codex in
a known-libraries scenario. Future work includes examining robustness of our
approach against obfuscation, a security-related evaluation, and further
exploration of the Java Trace Dataset.

## References

  * (1)
  * Al-Kaswan et al. (2023) A. Al-Kaswan, T. Ahmed, M. Izadi, A. Sawant, P. Devanbu, and A. van Deursen. 2023.  Extending Source Code Pre-Trained Language Models to Summarise Decompiled Binaries. In _2023 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER)_. IEEE Computer Society, Los Alamitos, CA, USA, 260–271.  https://doi.org/10.1109/SANER56733.2023.00033
  * Chen et al. (2021) Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. 2021\.  Evaluating large language models trained on code.  _arXiv preprint arXiv:2107.03374_ (2021).
  * Claudio Spiess (2023) Claudio Spiess. 2023.  _java-trace-dataset (Revision 905fe11)_.  https://doi.org/10.57967/hf/1020
  * Devlin et al. (2019) Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019.  BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding.  arXiv:1810.04805 (5 2019).  https://doi.org/10.48550/arXiv.1810.04805 arXiv:1810.04805 [cs].
  * Ding et al. (2019) Steven H. H. Ding, Benjamin C. M. Fung, and Philippe Charland. 2019.  Asm2Vec: Boosting Static Representation Robustness for Binary Clone Search against Code Obfuscation and Compiler Optimization. In _2019 IEEE Symposium on Security and Privacy (SP)_. 472–489.  https://doi.org/10.1109/SP.2019.00003
  * Duan et al. (2020) Yue Duan, Xuezixiang Li, Jinghan Wang, and Heng Yin. 2020.  DeepBinDiff: Learning Program-Wide Code Representations for Binary Diffing. In _27th Annual Network and Distributed System Security Symposium, NDSS 2020, San Diego, California, USA, February 23-26, 2020_. The Internet Society.  https://www.ndss-symposium.org/ndss-paper/deepbindiff-learning-program-wide-code-representations-for-binary-diffing/
  * Farhadi et al. (2014) Mohammad Reza Farhadi, Benjamin C.M. Fung, Philippe Charland, and Mourad Debbabi. 2014.  BinClone: Detecting Code Clones in Malware. In _2014 Eighth International Conference on Software Security and Reliability (SERE)_. 78–87.  https://doi.org/10.1109/SERE.2014.21
  * Feng et al. (2020) Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, Xiaocheng Feng, Ming Gong, Linjun Shou, Bing Qin, Ting Liu, Daxin Jiang, and Ming Zhou. 2020.  CodeBERT: A Pre-Trained Model for Programming and Natural Languages.  arXiv:2002.08155 (09 2020).  https://doi.org/10.48550/arXiv.2002.08155 arXiv:2002.08155 [cs].
  * Hu et al. (2018) Yikun Hu, Yuanyuan Zhang, Juanru Li, Hui Wang, Bodong Li, and Dawu Gu. 2018.  BinMatch: A Semantics-Based Hybrid Approach on Binary Code Clone Analysis. In _2018 IEEE International Conference on Software Maintenance and Evolution (ICSME)_. 104–114.  https://doi.org/10.1109/ICSME.2018.00019
  * Johnson et al. (2019) Jeff Johnson, Matthijs Douze, and Hervé Jégou. 2019.  Billion-scale similarity search with GPUs.  _IEEE Transactions on Big Data_ 7, 3 (2019), 535–547.
  * Lacomis et al. (2019) Jeremy Lacomis, Pengcheng Yin, Edward J. Schwartz, Miltiadis Allamanis, Claire Le Goues, Graham Neubig, and Bogdan Vasilescu. 2019.  DIRE: A Neural Approach to Decompiled Identifier Naming.  arXiv:1909.09029 (10 2019).  https://doi.org/10.48550/arXiv.1909.09029 arXiv:1909.09029 [cs].
  * Nashid et al. (2023) Noor Nashid, Mifta Sintaha, and Ali Mesbah. 2023.  Retrieval-based prompt selection for code-related few-shot learning. In _Proceedings of the 45th International Conference on Software Engineering (ICSE’23)_.
  * Pei et al. (2021) Kexin Pei, Zhou Xuan, Junfeng Yang, Suman Jana, and Baishakhi Ray. 2021.  Trex: Learning Execution Semantics from Micro-Traces for Binary Similarity.  arXiv:2012.08680 (4 2021).  https://doi.org/10.48550/arXiv.2012.08680 arXiv:2012.08680 [cs].
  * Ren et al. (2020) Shuo Ren, Daya Guo, Shuai Lu, Long Zhou, Shujie Liu, Duyu Tang, Neel Sundaresan, Ming Zhou, Ambrosio Blanco, and Shuai Ma. 2020.  CodeBLEU: a Method for Automatic Evaluation of Code Synthesis.  _arXiv:2009.10297 [cs]_ (9 2020).  http://arxiv.org/abs/2009.10297 arXiv: 2009.10297.
  * Robertson and Walker (1994) Stephen E Robertson and Steve Walker. 1994.  Some simple effective approximations to the 2-poisson model for probabilistic weighted retrieval. In _SIGIR’94: Proceedings of the Seventeenth Annual International ACM-SIGIR Conference on Research and Development in Information Retrieval, organised by Dublin City University_. Springer, 232–241.


# Soliton Confinement in a Quantum Circuit

Ananda Roy<EMAIL_ADDRESS>Department of Physics and
Astronomy, Rutgers University, Piscataway, NJ 08854-8019 USA  Sergei L.
Lukyanov<EMAIL_ADDRESS>Department of Physics and Astronomy,
Rutgers University, Piscataway, NJ 08854-8019 USA

###### Abstract

Confinement of topological excitations into particle-like states - typically
associated with theories of elementary particles - are known to occur in
condensed matter systems, arising as domain-wall confinement in quantum spin
chains. However, investigation of confinement in the condensed matter setting
has rarely ventured beyond lattice spin systems. Here, we analyze the
confinement of sine-Gordon solitons into mesonic bound states in a one-
dimensional, quantum electronic circuit (QEC) array, constructed using
experimentally-demonstrated circuit elements: Josephson junctions, capacitors
and $0-\pi$ qubits. The interactions occurring naturally in the QEC array, due
to tunneling of Cooper-pairs and pairs of Cooper-pairs, give rise to a non-
integrable, interacting, lattice model of quantum rotors. In the scaling
limit, the latter is described by the quantum sine-Gordon model, perturbed by
a cosine potential with a different periodicity. We compute the string tension
of confinement of sine-Gordon solitons and the changes in the low-lying
spectrum in the perturbed model. The scaling limit is reached faster for the
QEC array compared to conventional spin chain regularizations, allowing high-
precision numerical investigation of the strong-coupling regime of this non-
integrable quantum field theory. Our results, obtained using the density
matrix renormalization group method, could be verified in a quench experiment
using state-of-the-art QEC technologies.

Confinement and asymptotic freedom are paradigmatic examples of non-
perturbative effects in strongly interacting quantum field theories (QFTs)
[1]. While typically associated with theories of elementary particles [2, 3],
confinement of excitations into particle-like states occurs in a wide range
condensed matter systems. In the latter setting, the “hadrons” are formed due
to confinement of domain walls in quantum spin chains [4]. They have been
detected using neutron scattering experiments in a coupled spin-1/2 chains [5]
and in a one-dimensional Ising ferromagnet [6]. Furthermore, signatures of
confinement have been observed in numerical investigations of quenches in
quantum Ising spin chains [7, 8] as well as in noisy quantum simulators [9,
10].

Despite its ubiquitousness, in the condensed matter setting, quantitative
investigation of confinement has rarely ventured beyond lattice spin systems.
In this work, we show that confinement of topological excitations can arise in
a one-dimensional, superconducting, quantum electronic circuit (QEC) array.
The QEC array is constructed using experimentally-demonstrated quantum circuit
elements: Josephson junctions, capacitors and $0-\pi$ qubits [11, 12, 13, 14,
15, 16, 17]. The proposed QEC array departs from the established paradigm of
probing confinement in condensed matter systems and starts with lattice
quantum rotors. These lattice regularizations are particularly suitable for
simulating a large class of strongly-interacting bosonic QFTs [18] due to
rapid convergence to the scaling limit. While this was numerically observed in
the semi-classical regime of the sine-Gordon (sG) model [19], here we show
that QECs are suitable for regularizing a strong-interacting, non-integrable
bosonic QFT.

Figure 1:  Each unit cell (gray rectangle) of the QEC array contains a
Josephson junction (green cross) on the horizontal link. The vertical link of
the same contains a parallel circuit of an ordinary Josephson junction (blue
cross) and a $\cos(2\phi)$ Josephson junction (purple crosses). The latter is
formed by two Josephson junctions, two capacitors and two inductors (bottom
right panel) [14]. The variation of the classical potential, $V_{\rm cl}$,
[Eq. (1)] as $E_{J_{1}}/E_{J_{2}}$ increases from 0 in steps of 1/4 is shown
in the top right panel. For nonzero $E_{J_{1}}/E_{J_{2}}$, the solitons (green
wavepacket) and antisolitons (maroon wavepacket), interpolating between the
potential minima at $\phi=0$ and $\phi=\pi$, experience a confining potential
(yellow string in top left panel), leading to the formation of mesonic bound
states.

With a specific choice of interactions that arise naturally in QEC systems due
to tunneling of Cooper pairs and pairs of Cooper pairs, we verify that the
long-wavelength properties of the QEC array are described by a perturbed sG
(psG) model [20, 21, 22, 23, 24]. The corresponding euclidean action is

${\cal A}_{\rm psG}=\int\
d^{2}x\left[\frac{1}{16\pi}(\partial_{\nu}\varphi)^{2}+V(\varphi)\right],$ (1)

where $V(\varphi)=-2\mu\cos(\beta\varphi)-2\lambda\cos(\beta\varphi/2)$ and
$\lambda,\mu,\beta$ are parameters [25]. Due to the presence of the
perturbation $\propto\lambda$, the solitons and the antisolitons of the sG
model experience a confining potential that grows linearly with their
separation. This leads to the formation of mesonic excitations, analogous to
the confinement phenomena occurring in the Ising model with a longitudinal
field [26, 27, 28, 29, 30, 31]. In the psG case, the free Ising domain-walls
are replaced by interacting sG solitons. While predicted using semi-classical
and perturbative analysis [22, 23, 24], quantitative investigations of
confinement, direct evidence of the psG mesons and an experimentally-feasible
proposal to realize this model have remained elusive so far. This is performed
in this work.

Each unit cell of the one-dimensional QEC array [gray rectangle in Fig. 1]
contains: i) a Josephson junction on the horizontal link with junction energy
(capacitance) $E_{J}~{}(C_{J})$, ii) a parallel circuit of an ordinary
Josephson junction [junction energy (capacitance) $E_{J_{1}}~{}(C_{1})$] and a
$0-\pi$ qubit [11, 12, 13, 14] on the vertical link. The $0-\pi$ qubit is
realized using two Josephson junctions [junction energies (capacitances)
$E_{J}^{{}^{\prime}}~{}(C_{J}^{{}^{\prime}})$], together with two inductors
with inductances $L$ [Fig. 1(b)]. In the limit
$(L/C_{J}^{{}^{\prime}})^{1/2}\gg\hbar/(2e)^{2}$, this circuit configuration
realizes a $\cos(2\phi)$ Josephson junction [14]. In the limit $C_{J}\gg
C_{\rm eff}$, where $C_{\rm eff}=C_{1}+C_{2}$, the QEC array is described by
the Hamiltonian:

$\displaystyle H$ $\displaystyle=E_{c}\sum_{k=1}^{L}n_{k}^{2}+\epsilon
E_{c}\sum_{k=1}^{L}n_{k}n_{k+1}-E_{J}\sum_{k=1}^{L}\cos(\phi_{k}-\phi_{k+1})$
$\displaystyle\quad-
E_{g}\sum_{k=1}^{L}n_{k}-\sum_{a=1,2}E_{J_{a}}\sum_{k=1}^{L}\cos(a\phi_{k}),$
(2)

where $E_{c}=(2e)^{2}/2C_{\rm eff}$ and we have chosen periodic boundary
conditions. Here, $n_{k}$ is the excess number of Cooper pairs 111Note that
the eigenvalues of $n_{k}$-s can be both positive and negative integers, the
latter corresponding to creation of holes in the superconducting condensate on
the $k^{\rm th}$ island. on each superconducting island and $\phi_{k}$ is the
superconducting phase at each node, satisfying $[n_{j},{\rm e}^{\pm{\rm
i}\phi_{k}}]=\pm\hbar\delta_{jk}{\rm e}^{\pm{\rm i}\phi_{k}}$, with $\hbar$
set to 1 in the computations. We approximate the exponentially-decaying, long-
range interaction due to the capacitance $C_{J}$ [33] with a nearest-neighbor
interaction [34] of the form $\epsilon n_{k}n_{k+1}$, where the constant
$\epsilon$ is $<1$ 222The confinement phenomena described in this manuscript
would continue to exist in the case $\epsilon=0$.. The third and fourth terms
in Eq. (Soliton Confinement in a Quantum Circuit) arise due to the coherent
tunneling of Cooper-pairs between nearest-neighboring islands and due to a
gate-voltage at each node. The last two cosine potentials of Eq. (Soliton
Confinement in a Quantum Circuit) respectively arise from tunneling of Cooper-
pairs and pairs of Cooper-pairs through the Josephson junction and the $0-\pi$
qubit on the vertical link.

For $E_{J_{2}}=E_{J_{1}}=0$, $H$ corresponds to a variation of the Hamiltonian
of the Bose-Hubbard model [36, 37] and conserves the total number of Cooper-
pairs. As $E_{J}/E_{c}$ is increased from 0, the QEC array transitions from an
insulating to superconducting phase. We focus on the superconducting phase
obtained by increasing $E_{J}/E_{c}$ at constant density [38, 39]. In the
latter phase, the long-wavelength properties of the array are described by the
free, compactified boson QFT [34, 33], characterized by the algebraic decay of
the correlation function of the lattice vertex operator: $\langle{\rm e}^{{\rm
i}\phi_{j}}{\rm e}^{-{\rm i}\phi_{k}}\rangle\propto|j-k|^{-K/2}$, where $K$ is
the Luttinger parameter. This algebraic dependence is verified in Fig. 2(a) by
computing the corresponding correlation function using the density matrix
renormalization group (DMRG) technique [40]. For the parameters in this work,
the Luttinger parameter varies between $0\leq K\leq 2$ [34, 41]. We further
compute the dimensionless “Fermi/plasmon velocity”, $u$, in the QEC array by
analyzing the ground-state energy of the array with system-size (Ref. [25],
Sec. III) [Fig. 2(c)].

Figure 2:  DMRG results and comparison with analytical predictions. a)
Verification of the power-law decay of the correlation functions of the
lattice vertex operators for the free boson model obtained for
$E_{J_{1}}=E_{J_{2}}=0$ keeping $E_{J}/E_{c}$ finite. The obtained Luttinger
parameter ($K=2\beta^{2}$) from the slopes are plotted as pluses in c). b)
Scaling of the vertex operator expectation value with $E_{J_{2}}/E_{c}$ for
the sG model. The values of the sG coupling obtained from this scaling are
plotted as diamonds in c). The discrepancy between the sG result and the free-
boson prediction as $\beta^{2}\rightarrow 1$ occur due to corrections to
scaling arising from the Kosterlitz-Thouless phase-transition occurring at
$\beta^{2}=1$. The (dimensionless) Fermi/plasmon velocity, $u$, was obtained
from the Casimir energy computation of the free theory [25]. The free-fermion
point of the sG model is indicated by the dotted magenta line. d) Comparison
of the normalized, connected two-point correlation function of the vertex
operator ${\rm e}^{{\rm i}\phi_{j}}\sim$${\rm e}^{{\rm i}\beta\varphi/2}$
computed using DMRG and analytical computations in the repulsive
($\beta^{2}\approx 0.63$) and the attractive ($\beta^{2}\approx 0.4$, inset)
regimes of the sG model. The ratio $1/Mu$, $M$ being the soliton-mass, was
obtained by computing the correlation length from the infinite DMRG
computation.

For $E_{J_{2}}\neq 0,E_{J_{1}}=0$, keeping $E_{J}>E_{c}$, the QEC array
realizes the sG model [19]. Now, the lattice model has a conserved
$\mathbb{Z}_{2}$ symmetry, associated with the parity operator for the number
of Cooper-pairs: $P=\prod_{k=1}^{L}{\rm e}^{{\rm i}\pi n_{k}}$. This symmetry
leads to a two-fold degenerate ground state for this realization of the sG
model. This is in contrast to the usual continuum formulation of the latter,
where the ground state is one of the infinitely many vacua. The two degenerate
states correspond to $\phi_{k}=0$ and $\phi_{k}=\pi$, $k=1,\ldots,L$, with the
sG solitons and antisolitons interpolating between them. The sG coupling,
$\beta$, is given by: $\beta=\sqrt{K/2}\in(0,1)$ (Ref. [25], Sec. I).

We verify the sG limit of the QEC array as follows. First, we compute the
scaling of the lattice operator ${\rm e}^{{\rm i}\phi_{k}}$, which, in the
continuum limit, correspond to the vertex operator ${\rm e}^{{\rm
i}\beta\varphi/2}$. The scaling with the coupling $E_{J_{2}}/E_{c}$ [Fig.
2(b)] yields the value of the sG coupling $\beta^{2}$ [Fig. 2(c)]. These
values are compared with those expected from the free-boson computations. The
discrepancy between the obtained values of $\beta^{2}$ for the sG and the free
boson computations as $\beta^{2}\rightarrow 1$ arises due to the Kosterlitz-
Thouless phase-transition. We also compute the connected, two-point
correlation function: $\langle{{\rm e}}^{{\rm i}\phi_{j}}{{\rm e}}^{-{\rm
i}\phi_{k}}\rangle-\langle{\rm e}^{{\rm i}\phi_{j}}\rangle^{2}$. When
normalized by $\langle{{\rm e}}^{{\rm i}\phi_{j}}\rangle^{2}$, the latter is
given by a universal function, computable using analytical techniques. We
compare the DMRG results with analytical predictions. We chose two
representative values of $\beta^{2}$ to demonstrate the robustness of our
results in both the attractive and repulsive regimes. The quantity, $Mu$,
where $M$ is the soliton mass, is obtained numerically by computing the
correlation length of the lattice model using the infinite DMRG technique. The
short (long) distance behavior of the normalized, connected correlation
function was computed using conformal perturbation theory (form-factors [42,
43] computed by including up to two-particle contributions) (Ref. [25], Sec.
IB). The results are shown as pink (lime) solid curves labeled CPT (${\rm
FF_{2p}}$) in Fig. 2(d).

Figure 3:  a) DMRG results for the string tension for different choices of
$\beta^{2}$, chosen by fixing $E_{J}/E_{c}$ [Fig. 2(c)], for $L=64$. The
results are shown for $E_{J_{2}}/E_{c}=0.1$ for both the sG and psG models,
while for the latter, $E_{J_{1}}/E_{c}=0.1$. Similar results were obtained for
other choices. For the sG model (empty markers), after creating the soliton-
antisoliton pair, there is no associated energy cost of separation. However,
for the psG model (filled markers), due to the existence of the perturbing
cosine potential $\propto E_{J_{1}}$ [Eq. (Soliton Confinement in a Quantum
Circuit)], the soliton and the antisoliton experience a confining force. This
leads to an energy cost ($T/E_{c}$) growing linearly with separation $d$. b)
The corresponding phase-profile computed by creating a soliton-antisoliton
pair and separating them by 12 lattice sites. c) The corresponding string
tension, $\sigma=T/d$ (empty circles) obtained from a linear fit of the data
in a). The corresponding leading-order analytical predictions for $\sigma$ are
denoted by crosses. The discrepancy between the predicted and obtained string-
tension for $\beta^{2}\approx 0.736$ occurs due to the proximity to the
Kosterlitz-Thouless point ($\beta^{2}=1$).

The soliton-creating operators for the sG model [44, 45] are defined on the
lattice as: $O_{s}^{q}(k)={\rm e}^{2{\rm i}s\phi_{k}}\prod_{j<k}{\rm e}^{-{\rm
i}q\pi n_{j}}$, where $q$ and $s$ are the topological charge and the Lorentz
spin of the excitations. The current QEC incarnation of the sG model gives
access to solitons with $s\in\\{0,1/2,1\\}$ and $q=\pm 1$. For definiteness,
we consider $s=0$. Fig. 3(a) (empty markers) shows the energy cost, $T$, of
separating a soliton-antisoliton pair, after they are created by application
of $O_{s}^{q}$ at two different locations for different values of $\beta^{2}$.
For the sG model, as expected, $T=0$ for all values of the separation $d$. The
corresponding phase-profile can be inferred by computing $\langle{\rm e}^{{\rm
i}\phi_{k}}\rangle$ for different lattice sites, after normalizing with
respect to the ground-state results [Fig. 3(b)].

The situation changes dramatically for the psG model, realized by making
$E_{J_{1}}\neq 0$ in Eq. (Soliton Confinement in a Quantum Circuit), while
choosing the rest of the parameters as for the sG model. Due to the perturbing
potential $\sim\cos(\phi_{k})$, the sG solitons and the antisolitons
experience a strong-confining potential energy, qualitatively similar to that
experienced by the free, Ising domain walls under a longitudinal field [26,
27, 28, 29]. We compute the energy-cost of separation $T$ for the psG model as
in the sG case [Fig. 3(a), filled markers]. The energy-cost grows proportional
to the distance of separation: $T=\sigma d$, where $\sigma$ is the string-
tension. The latter is numerically obtained by fitting to this linear
dependence and shown as a function of $\beta$ in Fig. 3(c). To leading order,
$\sigma=2\langle{\rm e}^{{\rm i}\phi_{k}}\rangle E_{J_{1}}/E_{c}$, where the
expectation value $\langle{\rm e}^{{\rm i}\phi_{k}}\rangle$ is computed for
the ground state of $H$ with $E_{J_{1}}=0$. The discrepancy between the
leading-order prediction and the numerical results for $\beta^{2}\approx
0.736$ is due to the proximity to the Kosterlitz-Thouless point. The decrease
of the string-tension with increasing $\beta^{2}$ can be viewed as a
consequence of the increasing repulsion between the sG solitons and
antisolitons with increasing $\beta^{2}$.

Figure 4:  DMRG results for the mass of the lightest particle of the psG model
for $\beta^{2}<1/2$ (left) and $\beta^{2}>1/2$ (right), as a function of the
dimensionless quantity $\eta$. Here, $M~{}(m_{b})$ is the mass of the soliton
(lightest breather) of the unperturbed sG model. The diamonds and triangles
correspond to different choices of $E_{J_{2}}/E_{C}$. For small $\eta$, the
lightest particle is the lightest sG breather (psG meson) for
$\beta^{2}<(>)1/2$. Using linear fit [25] of the numerical data for $\eta\ll
1$, we obtain the ratio $m_{b}/M$ (comparison with the analytical prediction
in the left inset). The scaling of the psG meson mass is given by: $(m_{\rm
mes}-2M)/M\sim\eta^{\alpha}$ for $\eta\ll 1$. The inset in the right panel
shows the comparison of the $\alpha$ obtained using DMRG (circles) and those
using non-interacting two-particle (NI-2p) approximation (dotted line).

The spectrum of the psG model contains the newly-formed mesons and the charge-
neutral sG breathers. The latter occur only for $\beta^{2}<1/2$ with their
masses acquiring corrections due to the perturbing potential. Fig. 4 shows
DMRG results for mass of the lightest particle as a function of the
dimensionless parameter $\eta=[E_{J_{1}}/E_{c}]/[E_{J_{2}}/E_{c}]^{\nu}$,
$\nu=(1-\beta^{2}/4)/(1-\beta^{2})$, for different choices of
$E_{J_{2}}/E_{c}$. For small $\eta$, the psG mesons are heavier (with masses
$>2M$) than the breathers (with masses $<2M$). We compute the mass of the
lightest sG breather (psG meson) for $\beta^{2}<(>)1/2$ from computation of
the correlation lengths using infinite DMRG technique. For $\eta\ll 1$, the
correction to the lightest breather mass can be expanded in powers of $\eta$.
We show a comparison of the obtained ratio $m_{b}/M$, $m_{b}$ being the
lightest sG breather mass for $\eta=0$, with the analytical predictions in the
left inset. For a comparison of our numerical data with perturbative
computation [23], see Sec. IIB of Ref. [25]. For $\beta^{2}>1/2$, the spectrum
contains only the psG mesons. The dependence of lowest psG meson mass is shown
in Fig. 4 (right). For $\eta\ll 1$, a non-interacting two-particle (NI-2p)
computation (Ref. [25], Sec. IIC) predicts $(m_{\rm
mes}-2M)/M\sim\eta^{\alpha}$, where $\alpha=\frac{2}{3}$. Comparison of the
numerical results with the NI-2p computation is shown in the right inset. A
more complete computation using the Bethe-Salpeter equation for the psG model
is beyond the scope of this work.

To summarize, we have numerically demonstrated the confinement of sG solitons
into mesonic bound states in a QEC array. We computed the associated string
tension and computed the scaling properties of the mass of the lightest
particle. In contrast to quantum spin-chains which have been the defacto
standard for lattice simulation of strongly-interacting QFTs, this work
demonstrates the robustness and versatility of QEC to achieve this goal. Given
that the primitive circuit elements of the proposed scheme have already been
demonstrated, it is conceivable that predictions for additional physical
properties of the psG model could be obtained using analog quantum simulation
[46] in an experimental realization. For instance, a quench experiment would
be able to capture signatures of the excitations with energy higher than what
could reliably probed using DMRG. Consider the case when the junction energies
of the blue Josephson junctions, $E_{J_{1}}$, in Fig. 1 are tunable. This can
be accomplished by replacing the corresponding junctions by a SQUID loop with
a magnetic flux threading the latter [47]. After preparing the system in the
ground state of $H$ with $E_{J_{1}}=0$, the coupling $E_{J_{1}}$ is turned on
by tuning magnetic flux. Signatures of the confinement of the sG solitons can
be obtained by probing the spectrum and the current-current correlation
functions 333Note that imperfections in an experimental realization of the
$0-\pi$ qubit that lead to an additional $\cos\phi$ potential would
renormalize the coupling $E_{J_{1}}$ of Eq. (Soliton Confinement in a Quantum
Circuit) and does not pose an impediment towards investigation of the
confinement phenomena analyzed in this work.. Given the progress in the
fabrication and investigation of large QEC arrays [49, 50, 51], we are
optimistic of experimental vindication of our work.

The proposed QEC provides a starting point for the realization of a large
number of one-dimensional QFTs. First, replacing the blue Josephson junction
on the vertical link in Fig. 1 by a linear inductor gives rise to the renowned
massive Schwinger model. Second, tuning a magnetic flux between the Josephson
junction and the $0-\pi$ qubit in each cell changes the perturbing potential
in Eq. (Soliton Confinement in a Quantum Circuit) from $\cos(\phi_{k})$ to
$\sin(\phi_{k})$. For certain values of $E_{J_{1}}/E_{J_{2}}$, this induces a
renormalization group flow from the gapped perturbed sine-Gordon model to a
quantum critical point of Ising universality class [23, 24, 52]. Third, QECs
provide a robust avenue to realize sG models with $a$-fold degenerate minima,
where $a\in\mathbb{Z}$ (Ref. [25], Sec. IV). The corresponding $\cos(a\phi)$
circuit element can be constructed by recursively using the $\cos\phi$ and
$\cos 2\phi$ circuit elements. Perturbations of these sG models lead to not
only soliton confinement and false-vacuum decays [53, 54] present in the $a=2$
case, but also all unitary minimal conformal field theory models [55, 52].
Controlled realization of the latter multicritical Ising models opens the door
to numerical and experimental investigation of a wide range of impurity
problems that have so far been elusive.

The authors acknowledge discussions with Johannes Hauschild, Robert Konik,
Marton Kormos, Hubert Saleur, Gabor Takacs, and Yicheng Tang. AR was supported
from a grant from the Simons Foundation (825876, TDN). SL was supported by
NSF-PHY-2210187.

## References

  * Greensite [2011] J. Greensite,  _An introduction to the confinement problem_, Vol. 821 (2011).
  * Campana  _et al._ [2016] P. Campana, M. Klute, and P. Wells, Physics goals and experimental challenges of the proton–proton high-luminosity operation of the LHC, Annual Rev. of Nuclear and Particle Science 66, 273 (2016).
  * Busza  _et al._ [2018] W. Busza, K. Rajagopal, and W. van der Schee, Heavy ion collisions: The big picture and the big questions, Annual Rev. of Nuclear and Particle Science 68, 339 (2018).
  * McCoy and Wu [1978] B. M. McCoy and T. T. Wu, Two-dimensional ising field theory in a magnetic field: Breakup of the cut in the two-point function, Phys. Rev. D 18, 1259 (1978).
  * Lake  _et al._ [2009] B. Lake, A. M. Tsvelik, S. Notbohm, D. A. Tennant, T. G. Perring, M. Reehuis, C. Sekar, G. Krabbes, and B. Büchner, Confinement of fractional quantum number particles in a condensed-matter system, Nature Physics 6, 50 (2009).
  * Coldea  _et al._ [2010] R. Coldea, D. A. Tennant, E. M. Wheeler, E. Wawrzynska, D. Prabhakaran, M. Telling, K. Habicht, P. Smeibidl, and K. Kiefer, Quantum criticality in an ising chain: Experimental evidence for emergent $E_{8}$ symmetry, Science 327, 177 (2010).
  * Kormos  _et al._ [2016] M. Kormos, M. Collura, G. Takács, and P. Calabrese, Real-time confinement following a quantum quench to a non-integrable model, Nature Physics 13, 246 (2016).
  * Vovrosh  _et al._ [2022] J. Vovrosh, R. Mukherjee, A. Bastianello, and J. Knolle, Dynamical hadron formation in long-range interacting quantum spin chains, PRX Quantum 3, 040309 (2022).
  * Tan  _et al._ [2021] W. L. Tan, P. Becker, F. Liu, G. Pagano, K. S. Collins, A. De, L. Feng, H. B. Kaplan, A. Kyprianidis, R. Lundgren, W. Morong, S. Whitsitt, A. V. Gorshkov, and C. Monroe, Domain-wall confinement and dynamics in a quantum simulator, Nature Physics 17, 742 (2021).
  * Vovrosh and Knolle [2021] J. Vovrosh and J. Knolle, Confinement and entanglement dynamics on a digital quantum computer, Scientific Reports 11, 11577 (2021).
  * Douçot and Vidal [2002] B. Douçot and J. Vidal, Pairing of cooper pairs in a fully frustrated josephson-junction chain, Phys. Rev. Lett. 88, 227005 (2002).
  * Ioffe and Feigel’man [2002] L. B. Ioffe and M. V. Feigel’man, Possible realization of an ideal quantum computer in josephson junction array, Phys. Rev. B 66, 224503 (2002).
  * Kitaev [2006] A. Kitaev, Protected qubit based on a superconducting current mirror (2006), arXiv:cond-mat/0609441 .
  * Brooks  _et al._ [2013] P. Brooks, A. Kitaev, and J. Preskill, Protected gates for superconducting qubits, Phys. Rev. A 87, 052306 (2013).
  * Gladchenko  _et al._ [2008] S. Gladchenko, D. Olaya, E. Dupont-Ferrier, B. Douçot, L. B. Ioffe, and M. E. Gershenson, Superconducting nanocircuits for topologically protected qubits, Nature Physics 5, 48 (2008).
  * Smith  _et al._ [2020] W. C. Smith, A. Kou, X. Xiao, U. Vool, and M. H. Devoret, Superconducting circuit protected by two-Cooper-pair tunneling, NPJ Quantum Information 6, 8 (2020), arXiv:1905.01206 [quant-ph] .
  * Gyenis  _et al._ [2021] A. Gyenis, P. S. Mundada, A. Di Paolo, T. M. Hazard, X. You, D. I. Schuster, J. Koch, A. Blais, and A. A. Houck, Experimental realization of a protected superconducting circuit derived from the $0$–$\pi$ qubit, PRX Quantum 2, 010339 (2021).
  * Roy and Saleur [2019] A. Roy and H. Saleur, Quantum electronic circuit simulation of generalized sine-gordon models, Phys. Rev. B 100, 155425 (2019).
  * Roy  _et al._ [2021] A. Roy, D. Schuricht, J. Hauschild, F. Pollmann, and H. Saleur, The quantum sine-Gordon model with quantum circuits, Nucl. Phys. B 968, 115445 (2021), arXiv:quant-ph/2007.06874 .
  * Campbell  _et al._ [1986] D. K. Campbell, M. Peyrard, and P. Sodano, Kink-antikink interactions in the double sine-gordon equation, Physica D: Nonlinear Phenomena 19, 165 (1986).
  * Delfino  _et al._ [1996] G. Delfino, G. Mussardo, and P. Simonetti, Nonintegrable quantum field theories as perturbations of certain integrable models, Nucl. Phys. B 473, 469 (1996), arXiv:hep-th/9603011 .
  * Delfino and Mussardo [1998] G. Delfino and G. Mussardo, Non-integrable aspects of the multi-frequency sine-gordon model, Nuclear Physics B 516, 675–703 (1998).
  * Bajnok  _et al._ [2001] Z. Bajnok, L. Palla, G. Takacs, and F. Wagner, Nonperturbative study of the two frequency sine-Gordon model, Nucl. Phys. B 601, 503 (2001), arXiv:hep-th/0008066 .
  * Mussardo  _et al._ [2004] G. Mussardo, V. Riva, and G. Sotkov, Semiclassical particle spectrum of double sine-Gordon model, Nucl. Phys. B 687, 189 (2004), arXiv:hep-th/0402179 .
  * [25] See supplementary material for details.
  * Fonseca and Zamolodchikov [2003] P. Fonseca and A. Zamolodchikov, Ising field theory in a magnetic field: Analytic properties of the free energy, J. Stat. Phys. 110, 527 (2003).
  * Rutkevich [2005] S. B. Rutkevich, Large-$n$ excitations in the ferromagnetic ising field theory in a weak magnetic field: Mass spectrum and decay widths, Phys. Rev. Lett. 95, 250601 (2005).
  * Fonseca and Zamolodchikov [2006] P. Fonseca and A. Zamolodchikov, Ising spectroscopy. I. Mesons at $T<T_{c}$, (2006), arXiv:hep-th/0612304 .
  * Rutkevich [2008] S. B. Rutkevich, Energy spectrum of bound-spinons in the quantum ising spin-chain ferromagnet, J. Stat. Phys. 131, 917 (2008).
  * James  _et al._ [2019] A. J. A. James, R. M. Konik, and N. J. Robinson, Nonthermal states arising from confinement in one and two dimensions, Phys. Rev. Lett. 122, 130603 (2019).
  * Robinson  _et al._ [2019] N. J. Robinson, A. J. A. James, and R. M. Konik, Signatures of rare states and thermalization in a theory with confinement, Phys. Rev. B 99, 195108 (2019).
  * Note [1] Note that the eigenvalues of $n_{k}$-s can be both positive and negative integers, the latter corresponding to creation of holes in the superconducting condensate on the $k^{\rm th}$ island.
  * Goldstein  _et al._ [2013] M. Goldstein, M. H. Devoret, M. Houzet, and L. I. Glazman, Inelastic microwave photon scattering off a quantum impurity in a josephson-junction array, Phys. Rev. Lett. 110, 017002 (2013).
  * Glazman and Larkin [1997] L. I. Glazman and A. I. Larkin, New quantum phase in a one-dimensional josephson array, Phys. Rev. Lett. 79, 3736 (1997).
  * Note [2] The confinement phenomena described in this manuscript would continue to exist in the case $\epsilon=0$.
  * Fisher  _et al._ [1989] M. P. A. Fisher, P. B. Weichman, G. Grinstein, and D. S. Fisher, Boson localization and the superfluid-insulator transition, Phys. Rev. B 40, 546 (1989).
  * Sachdev [2011] S. Sachdev,  _Quantum Phase Transitions_ (Cambridge University Press, 2011).
  * Giamarchi [1997] T. Giamarchi, Mott transition in one dimension, Physica B: Condensed Matter 230-232, 975 (1997), proceedings of the International Conference on Strongly Correlated Electron Systems.
  * Kühner  _et al._ [2000] T. D. Kühner, S. R. White, and H. Monien, One-dimensional bose-hubbard model with nearest-neighbor interaction, Phys. Rev. B 61, 12474 (2000).
  * [40] The DMRG computations of this work were performed using the TeNPy package [56].
  * Roy  _et al._ [2020] A. Roy, F. Pollmann, and H. Saleur, Entanglement Hamiltonian of the 1+1-dimensional free, compactified boson conformal field theory, J. Stat. Mech. 2008, 083104 (2020), arXiv:cond-mat/2004.14370 .
  * Smirnov [1992] F. Smirnov,  _Form Factors in Completely Integrable Models of Quantum Field Theory_, Advanced series in mathematical physics (World Scientific, 1992).
  * Lukyanov [1997] S. L. Lukyanov, Form-factors of exponential fields in the sine-Gordon model, Mod. Phys. Lett. A 12, 2543 (1997), arXiv:hep-th/9703190 .
  * Mandelstam [1975] S. Mandelstam, Soliton operators for the quantized sine-gordon equation, Phys. Rev. D 11, 3026 (1975).
  * Lukyanov and Zamolodchikov [2001] S. Lukyanov and A. Zamolodchikov, Form factors of soliton-creating operators in the sine-gordon model, Nuclear Physics B 607, 437 (2001).
  * Feynman [1982] R. P. Feynman, Simulating Physics with Quantum Computers, Inernational Journal of Theoretical Physics 21, 467 (1982).
  * Tinkham [2004] M. Tinkham,  _Introduction to Superconductivity: Second Edition_, Dover Books on Physics (Dover Publications, 2004).
  * Note [3] Note that imperfections in an experimental realization of the $0-\pi$ qubit that lead to an additional $\mathop{cos}\nolimits\phi$ potential would renormalize the coupling $E_{J_{1}}$ of Eq. (Soliton Confinement in a Quantum Circuit) and does not pose an impediment towards investigation of the confinement phenomena analyzed in this work.
  * Kuzmin  _et al._ [2019] R. Kuzmin, N. Mehta, N. Grabon, R. Mencia, and V. E. Manucharyan, Superstrong coupling in circuit quantum electrodynamics, NPJ Quantum Information 5, 20 (2019).
  * Léger  _et al._ [2019] S. Léger, J. Puertas-Martínez, K. Bharadwaj, R. Dassonneville, J. Delaforce, F. Foroughi, V. Milchakov, L. Planat, O. Buisson, C. Naud, W. Hasch-Guichard, S. Florens, I. Snyman, and N. Roch, Observation of quantum many-body effects due to zero point fluctuations in superconducting circuits, Nature Communications 10, 5259 (2019).
  * Puertas Martínez  _et al._ [2019] J. Puertas Martínez, S. Léger, N. Gheeraert, R. Dassonneville, L. Planat, F. Foroughi, Y. Krupko, O. Buisson, C. Naud, W. Hasch-Guichard, S. Florens, I. Snyman, and N. Roch, A tunable josephson platform to explore many-body quantum optics in circuit-qed, NPJ Quantum Information 5, 19 (2019).
  * Roy [2023] A. Roy, Quantum Electronic Circuits for Multicritical Ising Models, (2023), arXiv:2306.04346 [quant-ph] .
  * Coleman [1977] S. Coleman, Fate of the false vacuum: Semiclassical theory, Phys. Rev. D 15, 2929 (1977).
  * Coleman [1988] S. Coleman,  _Aspects of Symmetry: Selected Erice Lectures_ (Cambridge University Press, 1988).
  * Zamolodchikov [1986] A. B. Zamolodchikov, Conformal Symmetry and Multicritical Points in Two-Dimensional Quantum Field Theory. (In Russian), Sov. J. Nucl. Phys. 44, 529 (1986).
  * Hauschild and Pollmann [2018] J. Hauschild and F. Pollmann, Efficient numerical simulations with Tensor Networks: Tensor Network Python (TeNPy), SciPost Phys. Lect. Notes , 5 (2018).