# Vanishing and non-vanishing persistent currents of various conserved
quantities

Hirokazu Kobayashi  Department of Applied Physics, University of Tokyo, Tokyo
113-8656, Japan.  Haruki Watanabe<EMAIL_ADDRESS>Department of
Applied Physics, University of Tokyo, Tokyo 113-8656, Japan.

###### Abstract

For every conserved quantity written as a sum of local terms, there exists a
corresponding current operator that satisfies the continuity equation. The
expectation values of current operators at equilibrium define the persistent
currents that characterize spontaneous flows in the system. In this work, we
consider quantum many-body systems on a finite one-dimensional lattice and
discuss the scaling of the persistent currents as a function of the system
size. We show that, when the conserved quantities are given as the Noether
charges associated with internal symmetries or the Hamiltonian itself, the
corresponding persistent currents can be bounded by a correlation function of
two operators at a distance proportional to the system size, implying that
they decay at least algebraically as the system size increases. In contrast,
the persistent currents of accidentally conserved quantities can be nonzero
even in the thermodynamic limit and even in the presence of the time-reversal
symmetry. We discuss ‘the current of energy current’ in $S=1/2$ XXZ spin chain
as an example and obtain an analytic expression of the persistent current.

Introduction.— The Noether theorem predicts the presence of a conserved
quantity for every global continuous symmetry Noether (1971); Weinberg (1995);
Altland and Simons (2010). This fundamental theorem underlies the conservation
of many important quantities such as the energy and the momentum in uniform
stationary systems and the U(1) charges in many-body systems. There can also
be other types of conserved quantities that commute with the Hamiltonian
without apparent symmetry reasons. Such quantities are the key behind the
integrability of exactly solvable models. They also affect the thermalization
property of the system Rigol  _et al._ (2007); Kollar  _et al._ (2011);
Cassidy  _et al._ (2011).

For each conserved quantity, one can define a current operator that satisfies
the continuity equation [see Eq. (1) below]. We call the expectation value of
current operators at equilibrium “persistent currents.” Persistent currents
can flow in systems which do not have any ends, such as the one-dimensional
ring illustrated in Fig. 1(a). Based on a variational argument that utilizes
the so-called ‘twist operator,’ Bloch showed that the persistent current for
the U(1) charge vanishes in the limit of large system size in quasi one-
dimensional systems Bohm (1949); Ohashi and Momoi (1996); Yamamoto (2015);
Watanabe (2019); Bachmann and Fraas (2021). Recently, Kapustin and Spodyneiko
proved a corresponding statement for the persistent energy current Kapustin
and Spodyneiko (2019). Their argument was rather a new approach focusing on
the current response towards deformations of the Hamiltonian.

Then natural questions arise: do the persistent currents of other conserved
quantities vanish in the thermodynamic limit, just like the persistent current
of the U(1) charge and the energy? If so, how do we prove it? What are their
scaling as a function of the system size? In this work, we answer these basic
questions one by one. It is known that current operators have ambiguities in
their definition. To address these questions in a meaningful manner, we should
first show that the persistent current is independent of such ambiguity.

Our analysis also provides an alternative proof of the absence of persistent
energy current in the thermodynamic limit. As compared to the one in Ref.
Kapustin and Spodyneiko (2019), our argument is advantageous in two ways: (i)
the finite-size scaling is accessible and (ii) the assumption of the absence
of a finite-temperature phase transition Kapustin and Spodyneiko (2019) is not
needed. Moreover, Bloch’s original approach for the U(1) current only provides
$O(L^{-1})$ bound regardless of the system size and the temperature Bohm
(1949); Ohashi and Momoi (1996); Yamamoto (2015); Watanabe (2019); Bachmann
and Fraas (2021) but our argument improves it to an exponential decay at a
finite temperature when the system size is large enough.

Figure 1:  The lattice $\Lambda$ with (a) the periodic boundary condition and
(b) the open boundary condition. The link between the sites $x$ and $x+1$ is
denoted by $\bar{x}$.

Setting.— We consider a quantum many-body system defined on a finite one-
dimensional lattice $\Lambda\equiv\\{1,2,\dots,L\\}$ ($L\in\mathbb{N}$). The
boundary condition is set to be periodic so that the distance between two
sites $x,y\in\Lambda$ is given by $d(x,y)\equiv\min_{n}|x-y+nL|$. For example,
the site $x=L$ is right next to $x=1$ because $d(L,1)=1$ [see Fig. 1(a)].
Hence, $x+nL$ ($n\in\mathbb{N}$) may be identified with $x\in\Lambda$. The
Hamiltonian of the system $\hat{H}\equiv\sum_{x=1}^{L}\hat{h}_{x}$ is given as
the sum of local terms $\hat{h}_{x}$ that are Hermitian and are supported
around $x$. The ranges of $\hat{h}_{x}$’s are bounded by a finite constant
$r_{h}\in\mathbb{N}$. The system is not necessarily translation invariant.

Suppose that there exists a Hermitian operator
$\hat{Q}\equiv\sum_{x=1}^{L}\hat{q}_{x}$ that commutes with the Hamiltonian.
The ranges of $\hat{q}_{x}$’s are also bounded by a finite constant
$r_{q}\in\mathbb{N}$. By definition, $[\hat{h}_{x},\hat{q}_{y}]=0$ if
$d(x,y)>r$ with $r\equiv r_{h}+r_{q}$. The system size $L$ is assumed to be
much bigger than $r$. When $\hat{q}_{x}$ generates a compact Lie group
exclusively at site $x$ (i.e., the range $r_{q}=0$), $\hat{q}_{x}$ must be
integer-valued in some unit, which we set $1$ by a proper normalization. In
such a case, the twist operator $\hat{U}\equiv\exp\big{[}2\pi
iL^{-1}\sum_{x=1}^{L}x\hat{q}_{x}\big{]}$ is well defined and Bloch’s
variational argument is applicable Bohm (1949); Ohashi and Momoi (1996);
Yamamoto (2015); Watanabe (2019); Bachmann and Fraas (2021). Here we proceed
without assuming such properties of $\hat{q}_{x}$.

Given $\hat{H}$ and $\hat{Q}$, we introduce a current operator associated with
the link $\bar{x}$ between $x$ and $x+1$ that satisfies the continuity
equation [see Fig. 1(a)]

$i[\hat{H},\sum_{z=x+1}^{x^{\prime}}\hat{q}_{z}]=\hat{j}_{\bar{x}}-\hat{j}_{\bar{x}^{\prime}}\quad(x^{\prime}>x).$
(1)

We assume that $\hat{j}_{\bar{x}}$ is localized around the link $\bar{x}$ with
a finite support. When $d(x,x^{\prime})\gg r$, the supports of
$\hat{j}_{\bar{x}}$ and $\hat{j}_{\bar{x}^{\prime}}$ in the right hand side do
not overlap and $\hat{j}_{\bar{x}}$ can be uniquely singled out, for the given
$\hat{h}_{x}$ and $\hat{q}_{x}$. Note that $\langle\hat{j}_{\bar{x}}\rangle$
is independent of the link $\bar{x}$. This is because, for any operator
$\hat{o}$,

$\langle[\hat{H},\hat{o}]\rangle=\langle\hat{H}\hat{o}\rangle-\langle\hat{o}\hat{H}\rangle=0,$
(2)

when the expectation value is computed with respect to the Gibbs state or the
ground state (or any eigenstate) of $\hat{H}$. We obtain
$\langle\hat{j}_{\bar{x}}\rangle=\langle\hat{j}_{\bar{x}^{\prime}}\rangle$ by
applying Eq. (2) to Eq. (1) Watanabe (2019).

The decomposition of $\hat{H}$ and $\hat{Q}$ into local terms $\hat{h}_{x}$
and $\hat{q}_{x}$ is not unique Kitaev (2006). Let
$\hat{H}=\sum_{x=1}^{L}\hat{h}_{x}^{\prime}$ and
$\hat{Q}=\sum_{x=1}^{L}\hat{q}_{x}^{\prime}$ be an alternative decomposition,
and let $\hat{j}_{\bar{x}}^{\prime}$ be the current operator corresponding to
this choice. Owing to the assumed locality of $\hat{q}_{x}$, we can write

$\sum_{z=x+1}^{x^{\prime}}\hat{q}_{z}^{\prime}=\sum_{z=x+1}^{x^{\prime}}\hat{q}_{z}+\delta\hat{q}_{\bar{x}}-\delta\hat{q}_{\bar{x}^{\prime}}$
(3)

using operators $\delta\hat{q}_{\bar{x}}$ and
$\delta\hat{q}_{\bar{x}^{\prime}}$ localized around $\bar{x}$ and
$\bar{x}^{\prime}$, respectively. Substituting this into the continuity
equation Eq. (1), we find
$\hat{j}_{\bar{x}}^{\prime}-\hat{j}_{\bar{x}}=i[\hat{H},\delta\hat{q}_{\bar{x}}]$.
Again applying Eq. (2), we conclude that $\langle\hat{j}_{\bar{x}}\rangle$ is
independent of the choice of local operators, despite that the current
operator itself may be ambiguous. A similar conclusion can be found in Refs.
Nardis  _et al._ (2019); Borsi  _et al._ (2020), but our discussion here is
slightly more general in that we assumed only the locality of $\hat{q}_{x}$.

Figure 2:  Persistent currents in the tight-binding model with
$t_{1}=-te^{-i\theta/L}$ and $t_{0}=\mu/2$. We set $t=1$, $\mu=\sqrt{2}$
(corresponding to the quarter filling), $\theta=\pi/2$, and $L=8n-4$
($n\in\mathbb{N}$). (a) The band dispersion $\varepsilon_{k}$ for $L=52$. (b)
The log-log plot of the persistent currents at $T=0$. Lines are obtained by
fitting. The slopes for the U(1) current and the energy current corresponds to
$L^{-1}$ and $L^{-3}$ decay. (c,d) The log-log and linear-log plot of the
persistent currents at $T=t/100$. We use the same color labels as in (b).

Tight-binding Model.— Before further presenting abstract arguments, let us
first discuss illustrative examples. We first consider a single-band tight-
binding model with hopping parameters $t_{d}\in\mathbb{C}$:

$\displaystyle\hat{H}=\sum_{x=1}^{L}\hat{h}_{x},\quad\hat{h}_{x}=\sum_{d=0}^{r_{h}}t_{d}\hat{c}_{x+d}^{\dagger}\hat{c}_{x}+\text{h.c.},$
(4)

where $\hat{c}_{x}$ is the annihilation operator of fermions at site
$x\in\Lambda$. Introducing the Fourier transformation
$\hat{c}_{k}^{\dagger}\equiv
L^{-1/2}\sum_{x=1}^{L}\hat{c}_{x}^{\dagger}e^{ikx}$ for $k=2\pi j/L$, we
obtain the diagonalized form
$\hat{H}=\sum_{k}\varepsilon_{k}\hat{c}_{k}^{\dagger}\hat{c}_{k}$. The band
dispersion $\varepsilon_{k}\equiv\sum_{d=0}^{r_{h}}t_{d}e^{-ikd}+\text{c.c.}$
defines the group velocity
$v_{k}\equiv\partial_{k}\varepsilon_{k}=-i\sum_{d=0}^{r_{h}}dt_{d}e^{-ikd}+\text{c.c}$.
The ground state in a $N$ fermion system is given by the Slater determinant of
the $N$-lowest energy states. We fix the filling $\nu=N/L$ in the canonical
ensemble, while $N$ will be automatically chosen by fully occupying states
with $\varepsilon_{k}<0$ in the ground canonical ensemble (the chemical
potential $\mu$ is included in $\varepsilon_{k}$ via $t_{0}=\mu/2$). For
brevity, here we assume that the ground state is unique and that states with
momentum $k$ in the range $k_{-}\leq k\leq k_{+}$ are occupied and those
outside are unoccupied in the ground state [see Fig. 2(a)].

Let us consider a Hermitian operator of the form

$\displaystyle\hat{Q}=\sum_{x=1}^{L}\hat{q}_{x},\quad\hat{q}_{x}=\sum_{d^{\prime}=0}^{r_{q}}q_{d^{\prime}}\hat{c}_{x+d^{\prime}}^{\dagger}\hat{c}_{x}+\text{h.c.},$
(5)

which commutes with the Hamiltonian as it is diagonal in the Fourier space:
$\hat{Q}=\sum_{k}q_{k}\hat{c}_{k}^{\dagger}\hat{c}_{k}$ with
$q_{k}\equiv\sum_{d^{\prime}=0}^{r_{q}}q_{d^{\prime}}e^{-ikd^{\prime}}+\text{c.c}$.
For example, $q_{k}=1$ for the U(1) charge
$\hat{q}_{x}=\hat{c}_{x}^{\dagger}\hat{c}_{x}$ and $q_{k}=\varepsilon_{k}$ for
the energy $\hat{q}_{x}=\hat{h}_{x}$. Using the continuity equation (1), we
identify the current operator
$\hat{j}_{\bar{x}}=\sum_{d=1}^{r_{h}}\sum_{d^{\prime\prime}=1}^{d}\hat{\sigma}_{x-d^{\prime\prime}+1}^{d}$,
where

$\displaystyle\hat{\sigma}_{x}^{d}\equiv\sum_{d^{\prime}=0}^{r_{q}}i(t_{d}^{*}q_{d^{\prime}}^{*}\hat{c}_{x}^{\dagger}\hat{c}_{x+d+d^{\prime}}+t_{d}^{*}q_{d^{\prime}}\hat{c}_{x+d^{\prime}}^{\dagger}\hat{c}_{x+d})+\text{h.c.}$
(6)

See Supplemental Material (SM) for the derivation. The averaged current
operator $\hat{\bar{j}}\equiv L^{-1}\sum_{x=1}^{L}\hat{j}_{\bar{x}}$ takes an
intuitive form
$\hat{\bar{j}}=L^{-1}\sum_{k}q_{k}v_{k}\hat{c}_{k}^{\dagger}\hat{c}_{k}$ in
the Fourier space, which is simply the charge $q_{k}$ multiplied by the group
velocity $v_{k}=\partial_{k}\varepsilon_{k}$. The persistent current
$\langle\hat{j}_{\bar{x}}\rangle=L^{-1}\sum_{k=k_{-}}^{k_{+}}q_{k}v_{k}$ at
$T=0$ can thus be evaluated by the Euler–Maclaurin formula:

$\displaystyle\langle\hat{j}_{\bar{x}}\rangle=\int_{k_{-}}^{k_{+}}\frac{q_{k}v_{k}}{2\pi}dk+\frac{q_{k_{+}}v_{k_{+}}+q_{k_{-}}v_{k_{-}}}{2L}+O(L^{-2}).$
(7)

Now we show that $\langle\hat{j}_{\bar{x}}\rangle$ vanishes in the large $L$
limit when $q_{k}$ is a function of $\varepsilon_{k}$ but not a function of
$v_{k}$. This is the case when $\hat{Q}$ is the U(1) charge and the
Hamiltonian itself. If we write $q_{k}=f^{\prime}(\varepsilon_{k})$
[$f(\varepsilon_{k})=\varepsilon_{k}$ for the U(1) charge and
$f(\varepsilon_{k})=\varepsilon_{k}^{2}/2$ for the energy], the first term in
Eq. (7) can be written as
$[f(\varepsilon_{k_{+}})-f(\varepsilon_{k_{-}})]/(2\pi)$, which is small
because $|\varepsilon_{k_{+}}-\varepsilon_{k_{-}}|=O(L^{-1})$ in the ground
state. In the canonical ensemble, $\varepsilon_{k_{\pm}}=O(1)$ and
$\langle\hat{j}_{\bar{x}}\rangle\propto L^{-1}$ in general. In the ground
canonical ensemble, $\varepsilon_{k_{\pm}}$ themselves are $O(L^{-1})$ and the
persistent energy current decays faster.

On the other hand, in more general cases, $q_{k}$ may not take the above form.
For example, we can re-use the above current operator $\hat{j}_{\bar{x}}$ as
an example of $\hat{q}_{x}$ in Eq. (5). Then the corresponding $q_{k}$ is
$v_{k}$ for the U(1) current and $\varepsilon_{k}v_{k}$ for the energy
current. In this case, the first term in Eq. (7) does not vanish in general.
We demonstrate these results in Fig. 2(b) using the simplest model with the
nearest neighbor hopping. We also show the result for a finite temperature
$T=t/100$ in Fig. 2(c,d), which demonstrates the crossover to the exponential
decay around $L\sim t/T$.

XXZ Spin Chain.—The above discussion heavily relies on the simplicity of the
noninteracting model. However, the key conclusion remains valid even in the
presence of interactions. As an example, let us consider the $S=1/2$ XXZ spin
chain. The Hamiltonian is $\hat{H}=\sum_{x=1}^{L}\hat{h}_{x}$ with

$\displaystyle\hat{h}_{x}=J^{2}\left(\frac{1}{2}\hat{s}_{x+1}^{+}\hat{s}_{x}^{-}+\frac{1}{2}\hat{s}_{x+1}^{-}\hat{s}_{x}^{+}+\Delta\hat{s}_{x+1}^{z}\hat{s}_{x}^{z}\right),$
(8)

where $\hat{s}_{x}^{\pm}=\hat{s}_{x}^{x}\pm i\hat{s}_{x}^{y}$ and
$\hat{s}_{x}^{z}$ are the spin $1/2$ operators at site $x\in\Lambda$. The
energy current operator for $\hat{q}_{x}=\hat{h}_{x}$ is given by
$\hat{j}_{\bar{x}}=i[\hat{h}_{x},\hat{h}_{x+1}]$ Zotos  _et al._ (1997). The
total energy current $\hat{Q}=\sum_{x=1}^{L}\hat{j}_{\bar{x}}$ commutes with
the Hamiltonian Zotos  _et al._ (1997), allowing us to discuss ‘the current of
the energy current’ Vasseur  _et al._ (2015); Vasseur and Moore (2016); Szász-
Schagrin  _et al._ (2021). We append the concrete expressions of these
operators in SM. Since the energy current are odd under the time-reversal
symmetry, ‘the current of energy current’ is even. Thus, it can flow even in
the presence of the time-reversal symmetry. In contrast, the total U(1)
current $\hat{Q}=\sum_{x=1}^{L}i[\hat{h}_{x},\hat{s}_{x+1}^{z}]$ corresponding
to $\hat{q}_{x}=\hat{s}_{x}^{z}$ and ‘the total current of energy current’ do
not commute with Hamiltonian unless $\Delta=0$.

The $\Delta=0$ point reduces the tight-binding model with $t_{1}=-J/2$ and
$k_{\pm}=\pm\pi/2$ and Eq. (7) gives
$\langle\hat{j}_{\bar{x}}\rangle=-J^{3}/(3\pi)$ in the large $L$ limit. For
more general values of $\Delta$, $\langle\hat{j}_{\bar{x}}\rangle$ can be
expressed in terms of correlation functions of up to four neighboring spin
operators. Using the results of Ref. Kato  _et al._ (2004), we find the
following expressions for $-1<\Delta\leq 1$ in the large $L$ limit (see SM):

$\displaystyle\langle\hat{j}_{\bar{x}}\rangle=J^{3}\frac{\pi\Delta-2(1-\Delta^{2})^{3/2}\zeta_{\eta}(3)}{8\pi},$
(9)
$\displaystyle\zeta_{\eta}(3)\equiv\int_{-\infty}^{+\infty}\frac{1}{\sinh(x-i\frac{\pi}{2})}\frac{\cosh[\eta(x-i\frac{\pi}{2})]}{\sinh^{3}[\eta(x-i\frac{\pi}{2})]}dx,$
(10)

where $\eta$ ($0\leq\eta<1$) is defined by $\Delta=\cos(\pi\eta)$. For
example, we find $\langle\hat{j}_{\bar{x}}\rangle=J^{3}[1-3\zeta(3)]/8$ at
$\Delta=1$ [$\zeta(z)$ is the Riemann zeta function] and
$\langle\hat{j}_{\bar{x}}\rangle\to-J^{3}/8$ as $\Delta\to-1$. The expressions
in Eqs. (9) and (10) are also valid for $\Delta>1$, for which we set
$\eta=i\eta^{\prime}$ with $\eta^{\prime}>0$. For example, we have
$\langle\hat{j}_{\bar{x}}\rangle\simeq-3J^{3}\Delta/8$ when $\Delta\gg 1$. Our
numerical results up to $26$ spins are presented in Fig. 3.

Figure 3:  The expectation value of ‘the current of the energy current’ in the
XXZ spin chain with $J=1$. Panels (a) and (b) display different ranges of
$\Delta$. Orange points are obtained by exact diagonalization for the $L=26$
chain. The blue solid curves are the analytic expression in Eq. (9) in the
thermodynamic limit. The red dashed line in (b) represents the asymptotic
behavior as $\Delta\rightarrow+\infty$ in the thermodynamic limit. The inset
in (a) checks the convergence as $L$ increases for $\Delta=0$ and $1$. The
fitting lines have the slope corresponding to the $L^{-2}$ correction.

Vanishing Persistent Current under Open Boundary Condition.—We have seen
through examples that not all persistent currents vanish in the large $L$
limit: the current associated with internal symmetries and the energy are
$O(L^{-1})$ but the current for accidentally conserved quantities are
$O(L^{0})$. To have a better understanding on these differences, here we
temporarily consider the open boundary condition (OBC) and prove that the
persistent current vanishes for any conserved quantity under OBC. This
consideration serves as the reference point when evaluating the persistent
current under periodic boundary condition (PBC) later.

The crucial difference between PBC and OBC lies in the definition of the
distance. Under OBC, the distance between two sites $x,y\in\Lambda$ is simply
given by $\tilde{d}(x,y)\equiv|x-y|$. Thus the sites $x=L$ and $x=1$ are at a
long distance [see Fig. 1(b)]. Let
$\hat{\tilde{H}}\equiv\sum_{x=1}^{L}\hat{\tilde{h}}_{x}$ be the Hamiltonian
under OBC, in which all interactions across the ‘seam’ between $x=L$ and $x=1$
are switched off. We demand that the local Hamiltonians remain unchanged in
the bulk, i.e., $\hat{\tilde{h}}_{x}=\hat{h}_{x}$ when $r_{h}<x<L-r_{h}+1$.
Near boundaries (i.e., $1\leq x\leq r_{h}$ or $L-r_{h}+1\leq x\leq L$),
$\hat{\tilde{h}}_{x}$’s are arbitrary as long as $\hat{\tilde{h}}_{x}$ is
supported around $x$ and its range is bounded by $r_{h}$.

Another important assumption on $\hat{\tilde{H}}$ is that there exists a
conserved charge $\hat{\tilde{Q}}\equiv\sum_{x=1}^{L}\hat{\tilde{q}}_{x}$ that
may differ from $\hat{Q}$ only near the boundaries. For example, in the case
of internal symmetries, one can set $\hat{\tilde{Q}}=\hat{Q}$ by symmetrizing
$\hat{\tilde{H}}$ using $e^{i\theta\hat{Q}}$. In contrast, accidentally
conserved quantities of $\hat{H}$ may not have a correspondence in
$\hat{\tilde{H}}$. For example, the total energy current in the XXZ model is
not conserved under OBC Grabowski and Mathieu (1996).

We assume that the current operator $\hat{\tilde{j}}_{\bar{x}}$, satisfying
the continuity equation

$\displaystyle
i[\hat{\tilde{H}},\sum_{z=x+1}^{x^{\prime}}\hat{\tilde{q}}_{z}]=\hat{\tilde{j}}_{\bar{x}}-\hat{\tilde{j}}_{\bar{x}^{\prime}}\quad(x^{\prime}>x),$
(11)

remains localized around the link $\bar{x}$ with a finite support. If we set
$x=0$ and $x^{\prime}=L$ in Eq. (11), we find
$\hat{\tilde{j}}_{\bar{L}}-\hat{\tilde{j}}_{\bar{0}}=-i[\hat{\tilde{H}},\hat{\tilde{Q}}]=0$.
Because of the assumed locality of $\hat{\tilde{j}}_{\bar{0}}$ and
$\hat{\tilde{j}}_{\bar{L}}$, this is equivalent with
$\hat{\tilde{j}}_{\bar{0}}=\hat{\tilde{j}}_{\bar{L}}=0.$ This is reasonable
since nothing can flow into or flow out of the system under OBC. Then, again
from Eq. (11), we find a compact expression of the current operator
$\hat{\tilde{j}}_{\bar{x}}=\sum_{z=x+1}^{L}i[\hat{\tilde{H}},\hat{\tilde{q}}_{z}]$,
which takes the form of $[\hat{\tilde{H}},\hat{o}]$. Thus the persistent
current, computed using the Gibbs state or the ground state of
$\hat{\tilde{H}}$, is precisely zero under OBC without the large $L$ limit.

Interpolating Hamiltonian.— Now, we return to the PBC in which the distance is
measured by $d(x,y)$. The Hamiltonian $\hat{\tilde{H}}$ for OBC can be
regarded as the Hamiltonian under PBC, since it satisfies the locality
condition. In contrast, the Hamiltonian $\hat{H}$ for PBC cannot be used under
OBC in general, since it may contain interactions between the two boundaries
$x=L$ and $1$ that are regarded as long-ranged with respect to
$\tilde{d}(x,y)$ of OBC.

We introduce a one-parameter family of Hamiltonians
$\hat{H}(s)=\sum_{x=1}^{L}\hat{h}_{x}(s)\equiv s\hat{H}+(1-s)\hat{\tilde{H}}$
for $s\in[0,1]$, which linearly interpolates our original Hamiltonian
$\hat{H}(1)=\hat{H}$ and the reference Hamiltonian
$\hat{H}(0)=\hat{\tilde{H}}$. By construction of $\hat{\tilde{H}}$, the local
Hamiltonians $\hat{h}_{x}(s)$ in the ‘bulk’ region does not depend on $s$,
i.e.,

$\hat{h}_{x}(s)=\hat{h}_{x},\quad r_{h}<x<L-r_{h}+1.$ (12)

In the following, we denote by $\langle\hat{o}\rangle_{s}$ the expectation
value with respect to the Gibbs state $\hat{\rho}(s)\equiv
Z(s)^{-1}e^{-\hat{H}(s)/T}$ [$Z(s)\equiv\text{tr}\,e^{-\hat{H}(s)/T}$] at a
finite $T$ or the ground state of $\hat{H}(s)$ at $T=0$.

We assume that, for any $s\in[0,1]$, the system has a conserved charge
$\hat{Q}(s)\equiv\sum_{x=1}^{L}\hat{q}_{x}(s)$ with $\hat{Q}(1)=\hat{Q}$ and
$\hat{Q}(0)=\hat{\tilde{Q}}$, in which $\hat{q}_{x}(s)$ is independent of $s$
at least when $x$ is away from $1$ and $L$:

$\hat{q}_{x}(s)=\hat{q}_{x}\quad\text{if}\quad 1\ll x\ll L.$ (13)

These assumptions are automatically fulfilled for the case of the Hamiltonian
$\hat{Q}(s)=\hat{H}(s)$. Also, for internal symmetries with
$\hat{Q}=\hat{\tilde{Q}}$, we can set $\hat{q}_{x}(s)=\hat{q}_{x}$ for any
$x\in\Lambda$ and $s\in[0,1]$. Substituting Eqs. (12) and (13) into the
continuity equation

$\displaystyle
i[\hat{H}(s),\sum_{z=x+1}^{x^{\prime}}\hat{q}_{z}(s)]+\hat{j}_{\bar{x}^{\prime}}(s)-\hat{j}_{\bar{x}}(s)=0\,\,\,\,(x^{\prime}>x),$
(14)

we find that the current operator $\hat{j}_{\bar{x}}(s)$ is also independent
of $s$ when $x$ is away from $1$ and $L$.

Figure 4:  $g_{s}(\hat{j}_{\bar{x}_{0}},\hat{u}_{\bar{L}})$ for the U(1)
current in the tight-binding model in Fig. 2. We set $t=1$ and $\theta=\pi/2$.
The lines in the panel (b) are obtained by fitting. The power $p_{s}$ is $1$
for $0\leq s<1$ except $p_{1}=2$.

Bound for the Persistent Current.— With these preparations, let us evaluate
$\langle\hat{j}_{\bar{x}}\rangle$ for the original Hamiltonian $\hat{H}$. Let
$x_{0}\in\Lambda$ be a site away from $x=1$ and $L$. We have

$\displaystyle\langle\hat{j}_{\bar{x}}\rangle$
$\displaystyle=\langle\hat{j}_{\bar{x}_{0}}\rangle_{s=1}=\int_{0}^{1}ds\,\partial_{s}\langle\hat{j}_{\bar{x}_{0}}\rangle_{s},$
(15)

where we used the fact that $\langle\hat{j}_{\bar{x}}\rangle$ is independent
of $\bar{x}$ and that $\hat{j}_{\bar{x}_{0}}(s)$ is $s$ independent as long as
$1\ll x_{0}\ll L$. The last equality is the absence of the persistent current
under OBC as discussed above.

According to the linear response theory, the derivative
$\partial_{s}\langle\hat{j}_{\bar{x}_{0}}\rangle_{s}$ is given by a
correlation function
$\partial_{s}\langle\hat{j}_{\bar{x}_{0}}\rangle_{s}=-g_{s}(\hat{j}_{\bar{x}_{0}},\hat{u}_{\bar{L}})$,
where
$\hat{u}_{\bar{L}}\equiv\partial_{s}\hat{H}(s)=\sum_{x=1}^{L}(\hat{h}_{x}-\hat{\tilde{h}}_{x})$
is localized around the link $\bar{L}$ between $x=L$ and $x=1$. At a finite
$T$,
$g_{s}(\hat{o},\hat{o}^{\prime})=T^{-1}\langle\langle\hat{o},\hat{o}^{\prime}\rangle\rangle_{s}$
is given by is the canonical correlation

$\displaystyle\langle\langle\hat{o},\hat{o}^{\prime}\rangle\rangle_{s}$
$\displaystyle\equiv
T\int_{0}^{T^{-1}}d\alpha\big{\langle}e^{\alpha\hat{H}(s)}\hat{o}e^{-\alpha\hat{H}(s)}\hat{o}^{\prime}\big{\rangle}_{s}-\langle\hat{o}\rangle_{s}\langle\hat{o}^{\prime}\rangle_{s},$
(16)

and, at $T=0$,

$g_{s}(\hat{o},\hat{o}^{\prime})=\Big{\langle}\hat{o}\frac{1-\hat{P}(s)}{\hat{H}(s)-E_{0}(s)}\hat{o}^{\prime}\Big{\rangle}_{s}+\text{c.c.},$
(17)

where $\hat{P}(s)$ is the projection onto the ground state of $\hat{H}(s)$ and
$E_{0}(s)$ is the ground state energy. Because of the property
$g_{s}([\hat{H}(s),\hat{o}],\hat{o}^{\prime})=\langle[\hat{o}^{\prime},\hat{o}]\rangle_{s}$,
$g_{s}(\hat{j}_{\bar{x}_{0}},\hat{u}_{\bar{L}})$ is independent of $x_{0}$ as
long as $1\ll x_{0}\ll L$. Up to this point, all expressions are exact.

Now, recall that $\hat{j}_{\bar{x}_{0}}$ and $\hat{u}_{\bar{L}}$ are
respectively localized around the link $\bar{x}_{0}$ and $\bar{L}$. If $x_{0}$
is set to be $L/2$ when $L$ is even and $(L+1)/2$ when $L$ is odd, the
distance between the supports of these two operators can be approximated by
$L/2$. Hence, even in gapless systems,
$g_{s}(\hat{j}_{\bar{x}_{0}},\hat{u}_{\bar{L}})$ should decay as $L$
increases. Let us postulate the power-law decay, i.e.,
$|g_{s}(\hat{j}_{\bar{x}_{0}},\hat{u}_{\bar{L}})|<c_{s}L^{-p_{s}}$ first. For
example, Fig. 3 illustrates the case for the above tight-biding model at
$T=0$. In this case, the persistent current can be bounded as

$\displaystyle|\langle\hat{j}_{\bar{x}}\rangle|\leq\int_{0}^{1}ds|g_{s}(\hat{j}_{\bar{x}_{0}},\hat{u}_{\bar{L}})|\leq
cL^{-p}$ (18)

with $c\equiv\max_{s}c_{s}$ and $p\equiv\min_{s}p_{s}$. In contrast, when the
correlation function decays exponentially, i.e.,
$|g_{s}(\hat{j}_{\bar{x}_{0}},\hat{u}_{\bar{L}})|\leq
c_{s}^{\prime}e^{-L/\xi_{s}}$, we instead have

$\displaystyle|\langle\hat{j}_{\bar{x}}\rangle|\leq\int_{0}^{1}ds|g_{s}(\hat{j}_{\bar{x}_{0}},\hat{u}_{\bar{L}})|\leq
c^{\prime}e^{-L/\xi}$ (19)

with $c^{\prime}\equiv\max_{s}c_{s}^{\prime}$ and $\xi\equiv\max_{s}\xi_{s}$.
In gapless systems at a finite temperature, if the gapless mode has the
velocity $v$, a crossover from the algebraic-decay regime ($L\lesssim v/T$) to
the exponential-decay regime ($L\gtrsim v/T$) is expected in general Giamarchi
(2003); Korepin  _et al._ (1993), as we have seen in Fig. 2(c,d).

Conclusions.— In this work, we considered a process in which all interactions
across the seam between $x=L$ and $x=1$ are gradually switched off. When the
quantity $\hat{Q}$, possibly modified in accordance with the Hamiltonian,
remains conserved during this process, the persistent current can be bounded
by a correlation function of two operators separated by $L/2$ as in Eqs. (18)
and (19). This is the case for internal symmetries and the Hamiltonian itself.
In contrast, when $\hat{Q}$ fails to be conserved during the process, this
argument is not applicable and the persistent current can be nonzero even in
the large $L$ limit. The mechanism for nonvanishing persistent currents here
is different from the anomalous mechanism proposed recently Else and Senthil
(2021); Watanabe . Although our discussion was limited to (quasi) one-
dimensional systems, several implications on higher dimensional systems can be
derived in the same way as in Ref. Watanabe (2019).

###### Acknowledgements.

We would like to thank Yohei Fuji, Hosho Katsura, Masaki Oshikawa, and Hal
Tasaki for useful discussions. The work of H.W. is supported by JSPS KAKENHI
Grant No. JP20H01825 and by JST PRESTO Grant No. JPMJPR18LA.

## References

  * Noether (1971) E. Noether, Transport Theory and Statistical Physics 1, 186 (1971).
  * Weinberg (1995) S. Weinberg,  _The Quantum Theory of Fields_ , Vol. I: Foundations (Cambridge University Press, 1995).
  * Altland and Simons (2010) A. Altland and B. Simons,  _Condensed Matter Field Theory_ , 2nd ed. (Cambridge University Press, 2010).
  * Rigol  _et al._ (2007) M. Rigol, V. Dunjko, V. Yurovsky, and M. Olshanii, Phys. Rev. Lett. 98, 050405 (2007).
  * Kollar  _et al._ (2011) M. Kollar, F. A. Wolf, and M. Eckstein, Phys. Rev. B 84, 054304 (2011).
  * Cassidy  _et al._ (2011) A. C. Cassidy, C. W. Clark, and M. Rigol, Phys. Rev. Lett. 106, 140405 (2011).
  * Bohm (1949) D. Bohm, Phys. Rev. 75, 502 (1949).
  * Ohashi and Momoi (1996) Y. Ohashi and T. Momoi, J. Phys. Soc. Jpn. 65, 3254 (1996).
  * Yamamoto (2015) N. Yamamoto, Phys. Rev. D 92, 085011 (2015).
  * Watanabe (2019) H. Watanabe, J. Stat. Phys. 177, 717 (2019).
  * Bachmann and Fraas (2021) S. Bachmann and M. Fraas, Rev. Math. Phys. 33, 2060011 (2021).
  * Kapustin and Spodyneiko (2019) A. Kapustin and L. Spodyneiko, Phys. Rev. Lett. 123, 060601 (2019).
  * Kitaev (2006) A. Kitaev, Ann. Phys. 321, 2 (2006).
  * Nardis  _et al._ (2019) J. D. Nardis, D. Bernard, and B. Doyon, SciPost Phys. 6, 49 (2019).
  * Borsi  _et al._ (2020) M. Borsi, B. Pozsgay, and L. Pristyák, Phys. Rev. X 10, 011054 (2020).
  * Zotos  _et al._ (1997) X. Zotos, F. Naef, and P. Prelovsek, Phys. Rev. B 55, 11029 (1997).
  * Vasseur  _et al._ (2015) R. Vasseur, C. Karrasch, and J. E. Moore, Phys. Rev. Lett. 115, 267201 (2015).
  * Vasseur and Moore (2016) R. Vasseur and J. E. Moore, J. Stat. Mech. 2016, 064010 (2016).
  * Szász-Schagrin  _et al._ (2021) D. Szász-Schagrin, B. Pozsgay, and G. Takács, SciPost Phys. 11, 37 (2021).
  * Kato  _et al._ (2004) G. Kato, M. Shiroishi, M. Takahashi, and K. Sakai, J. Phys. A: Math. Gen. 37, 5097 (2004).
  * Grabowski and Mathieu (1996) M. P. Grabowski and P. Mathieu, J. Phys. A: Math. Gen. 29, 7635 (1996).
  * Giamarchi (2003) T. Giamarchi,  _Quantum physics in one dimension_ , Vol. 121 (Clarendon press, 2003).
  * Korepin  _et al._ (1993) V. E. Korepin, N. M. Bogoliubov, and A. G. Izergin,  _Quantum inverse scattering method and correlation functions_ (Cambridge University Press, 1993).
  * Else and Senthil (2021) D. V. Else and T. Senthil, Phys. Rev. B 104, 205132 (2021).
  * (25) H. Watanabe, arXiv:2107.05211 .

##  Appendix A A. Current operators in the tight-binding model

The Hamiltonian $\hat{H}$ and the conserved charge $\hat{Q}$ are given by

$\displaystyle\hat{H}=\sum_{x=1}^{L}\hat{h}_{x}=\sum_{k}\varepsilon_{k}\hat{c}_{k}^{\dagger}\hat{c}_{k},\quad\hat{h}_{x}=\sum_{d=0}^{r_{h}}(t_{d}^{*}\hat{c}_{x}^{\dagger}\hat{c}_{x+d}+t_{d}\hat{c}_{x+d}^{\dagger}\hat{c}_{x}),\quad\varepsilon_{k}=\sum_{d=0}^{r_{h}}(t_{d}^{*}e^{ikd}+t_{d}e^{-ikd}),$
(20)
$\displaystyle\hat{Q}=\sum_{x=1}^{L}\hat{q}_{x}=\sum_{k}q_{k}\hat{c}_{k}^{\dagger}\hat{c}_{k},\quad\hat{q}_{x}=\sum_{d^{\prime}=0}^{r_{q}}(q_{d^{\prime}}^{*}\hat{c}_{x}^{\dagger}\hat{c}_{x+d^{\prime}}+q_{d^{\prime}}\hat{c}_{x+d^{\prime}}^{\dagger}\hat{c}_{x}),\quad
q_{k}=\sum_{d^{\prime}=0}^{r_{q}}(q_{d^{\prime}}^{*}e^{ikd^{\prime}}+q_{d^{\prime}}e^{-ikd^{\prime}}).$
(21)

The continuity equation reads

$\displaystyle\hat{j}_{\bar{x}-1}-\hat{j}_{\bar{x}}$
$\displaystyle=i[\hat{H},\hat{q}_{x}]=i\sum_{y=1}^{L}\sum_{d=0}^{r_{h}}\sum_{d^{\prime}=0}^{r_{q}}[t_{d}^{*}\hat{c}_{y}^{\dagger}\hat{c}_{y+d}+t_{d}\hat{c}_{y+d}^{\dagger}\hat{c}_{y},q_{d^{\prime}}^{*}\hat{c}_{x}^{\dagger}\hat{c}_{x+d^{\prime}}+q_{d^{\prime}}\hat{c}_{x+d^{\prime}}^{\dagger}\hat{c}_{x}]$
$\displaystyle=\sum_{d=0}^{r_{h}}\sum_{d^{\prime}=0}^{r_{q}}\left[i(t_{d}^{*}q_{d^{\prime}}^{*}\hat{c}_{x-d}^{\dagger}\hat{c}_{x+d^{\prime}}-t_{d}q_{d^{\prime}}\hat{c}_{x+d^{\prime}}^{\dagger}\hat{c}_{x-d})+i(t_{d}^{*}q_{d^{\prime}}\hat{c}_{x+d^{\prime}-d}^{\dagger}\hat{c}_{x}-t_{d}q_{d^{\prime}}^{*}\hat{c}_{x}^{\dagger}\hat{c}_{x+d^{\prime}-d})\right]$
$\displaystyle\quad-\sum_{d=0}^{r_{h}}\sum_{d^{\prime}=0}^{r_{q}}\left[i(t_{d}^{*}q_{d^{\prime}}^{*}\hat{c}_{x}^{\dagger}\hat{c}_{x+d+d^{\prime}}-t_{d}q_{d^{\prime}}\hat{c}_{x+d+d^{\prime}}^{\dagger}\hat{c}_{x})+i(t_{d}^{*}q_{d^{\prime}}\hat{c}_{x+d^{\prime}}^{\dagger}\hat{c}_{x+d}-t_{d}q_{d^{\prime}}^{*}\hat{c}_{x+d}^{\dagger}\hat{c}_{x+d^{\prime}})\right]$
$\displaystyle\equiv\sum_{d=0}^{r_{h}}(\hat{\sigma}_{x-d}^{d}-\hat{\sigma}_{x}^{d}).$
(22)

where $\hat{\sigma}_{x}^{d}$ is given in Eq. (6) of the main text. Therefore,
the current operator can be identified as

$\displaystyle\hat{j}_{\bar{x}}=\sum_{d=1}^{r_{h}}\sum_{d^{\prime\prime}=1}^{d}\hat{\sigma}_{x-d^{\prime\prime}+1}^{d},$
(23)
$\displaystyle\hat{\bar{j}}=\frac{1}{L}\sum_{d=0}^{r_{h}}d\sum_{x=1}^{L}\hat{\sigma}_{x}^{d}=\frac{1}{L}\sum_{k}\sum_{d=0}^{r_{h}}id(t_{d}^{*}e^{ikd}-t_{d}e^{-ikd})\sum_{d^{\prime}=0}^{r_{q}}(q_{d^{\prime}}^{*}e^{ikd^{\prime}}+q_{d^{\prime}}e^{-ikd^{\prime}})\hat{c}_{k}^{\dagger}\hat{c}_{k}=\frac{1}{L}\sum_{k}q_{k}\partial_{k}\varepsilon_{k}\hat{c}_{k}^{\dagger}\hat{c}_{k}.$
(24)

##  Appendix B B. The current of energy current in the XXZ spin chain

The Hamiltonian $\hat{H}$ and the energy current operator
$\hat{j}_{\bar{x}}^{\text{E}}$ are given by

$\displaystyle\hat{H}$
$\displaystyle=\sum_{x=1}^{L}\hat{h}_{x},\quad\hat{h}_{x}=J\left(\frac{1}{2}\hat{s}_{x+1}^{+}\hat{s}_{x}^{-}+\frac{1}{2}\hat{s}_{x+1}^{-}\hat{s}_{x}^{+}+\Delta\hat{s}_{x+1}^{z}\hat{s}_{x}^{z}\right),$
(25) $\displaystyle\hat{j}_{\bar{x}}^{\text{E}}$
$\displaystyle=i[\hat{h}_{x},\hat{h}_{x+1}]=\frac{iJ^{2}}{2}\big{(}\hat{s}_{x+2}^{+}\hat{s}_{x+1}^{z}\hat{s}_{x}^{-}-\Delta\hat{s}_{x+2}^{z}\hat{s}_{x+1}^{+}\hat{s}_{x}^{-}-\Delta\hat{s}_{x+2}^{+}\hat{s}_{x+1}^{-}\hat{s}_{x}^{z}\big{)}+\text{h.c.}$
(26)

The current operator of the energy current, i,e, the operator
$\hat{j}_{\bar{x}}$ satisfying the continuity equation (1) for
$\hat{q}_{x}=\hat{j}_{\bar{x}}^{\text{E}}$, is

$\displaystyle\hat{j}_{\bar{x}}$
$\displaystyle=\frac{J^{3}}{8}\left(\hat{s}^{+}_{x+2}\hat{s}^{-}_{x+1}-4\hat{s}^{+}_{x+3}\hat{s}^{z}_{x+2}\hat{s}^{z}_{x+1}\hat{s}^{-}_{x}\right)+\text{h.c.}+\frac{J^{3}\Delta^{2}}{8}\left(\hat{s}^{+}_{x+2}\hat{s}^{-}_{x+1}-4\hat{s}^{z}_{x+3}\hat{s}^{+}_{x+2}\hat{s}^{-}_{x+1}\hat{s}^{z}_{x}\right)+\text{h.c.}$
$\displaystyle\quad+\frac{J^{3}\Delta}{4}\left(2\hat{s}^{+}_{x+3}\hat{s}^{z}_{x+2}\hat{s}^{-}_{x+1}\hat{s}^{z}_{x}+2\hat{s}^{z}_{x+3}\hat{s}^{+}_{x+2}\hat{s}^{z}_{x+1}\hat{s}^{-}_{x}-\hat{s}^{+}_{x+3}\hat{s}^{-}_{x+2}\hat{s}^{+}_{x+1}\hat{s}^{-}_{x}+\hat{s}^{+}_{x+3}\hat{s}^{-}_{x+2}\hat{s}^{-}_{x+1}\hat{s}^{+}_{x}+\hat{s}^{z}_{x+2}\hat{s}^{z}_{x+1}\right)+\text{h.c.}$
(27)

Generalizations to the XYZ spin chain and to the XXZ model with U(1) flux are
straightforward. A similar expression was presented in Sec. 2.1 of Ref. Szász-
Schagrin  _et al._ (2021) but there were several typos in coefficients and
superscripts.

The expectation value is given in terms of the equal-time correlation
functions:

$\displaystyle\langle\hat{j}_{\bar{x}}\rangle/J^{3}$
$\displaystyle=\frac{1}{8}\left[\langle\hat{s}^{+}_{2}\hat{s}^{-}_{1}+\hat{s}^{+}_{1}\hat{s}^{-}_{2}\rangle-4(\langle\hat{s}^{+}_{4}\hat{s}^{z}_{3}\hat{s}^{z}_{2}\hat{s}^{-}_{1}\rangle+\langle\hat{s}^{+}_{1}\hat{s}^{z}_{2}\hat{s}^{z}_{3}\hat{s}^{-}_{4}\rangle)\right]$
$\displaystyle\quad+\frac{\Delta^{2}}{8}\left[\langle\hat{s}^{+}_{2}\hat{s}^{-}_{1}+\hat{s}^{+}_{1}\hat{s}^{-}_{2}\rangle-4(\langle\hat{s}^{z}_{4}\hat{s}^{+}_{3}\hat{s}^{-}_{2}\hat{s}^{z}_{1}\rangle+\langle\hat{s}^{z}_{1}\hat{s}^{+}_{2}\hat{s}^{-}_{3}\hat{s}^{z}_{4}\rangle)\right]$
$\displaystyle\quad+\frac{\Delta}{2}\left[(\langle\hat{s}^{+}_{4}\hat{s}^{z}_{3}\hat{s}^{-}_{2}\hat{s}^{z}_{1}\rangle+\langle\hat{s}^{z}_{1}\hat{s}^{+}_{2}\hat{s}^{z}_{3}\hat{s}^{-}_{4}\rangle)+(\langle\hat{s}^{z}_{4}\hat{s}^{+}_{3}\hat{s}^{z}_{2}\hat{s}^{-}_{1}\rangle+\langle\hat{s}^{+}_{1}\hat{s}^{z}_{2}\hat{s}^{-}_{3}\hat{s}^{z}_{4}\rangle)\right]$
$\displaystyle\quad+\frac{\Delta}{4}\left[-(\langle\hat{s}^{+}_{4}\hat{s}^{-}_{3}\hat{s}^{+}_{2}\hat{s}^{-}_{1}\rangle+\langle\hat{s}^{+}_{1}\hat{s}^{-}_{2}\hat{s}^{+}_{3}\hat{s}^{-}_{4}\rangle)+(\langle\hat{s}^{+}_{4}\hat{s}^{-}_{3}\hat{s}^{-}_{2}\hat{s}^{+}_{1}\rangle+\langle\hat{s}^{-}_{1}\hat{s}^{+}_{2}\hat{s}^{+}_{3}\hat{s}^{-}_{4}\rangle)+2\langle\hat{s}^{z}_{2}\hat{s}^{z}_{1}\rangle\right]$
$\displaystyle=\frac{1}{4}\left(F\begin{bmatrix}+&-\\\
-&+\end{bmatrix}+2F\begin{bmatrix}+&+&-&-\\\
-&+&-&+\end{bmatrix}-2F\begin{bmatrix}+&+&+&-\\\
-&+&+&+\end{bmatrix}\right)+\frac{\Delta^{2}}{2}\left(F\begin{bmatrix}+&-\\\
-&+\end{bmatrix}-2F\begin{bmatrix}+&+&-&+\\\ +&-&+&+\end{bmatrix}\right)$
$\displaystyle\quad+\frac{\Delta}{4}\left(8F\begin{bmatrix}+&+&+&-\\\
+&-&+&+\end{bmatrix}-4F\begin{bmatrix}+&+&-\\\
-&+&+\end{bmatrix}+2F\begin{bmatrix}+&-&-&+\\\
-&+&+&-\end{bmatrix}-2F\begin{bmatrix}+&-&+&-\\\
-&+&-&+\end{bmatrix}+2F\begin{bmatrix}+&+\\\
+&+\end{bmatrix}-F\begin{bmatrix}+\\\ +\end{bmatrix}\right).$ (28)

In the last line, we rewrote correlation functions using the $F$ symbol
defined in Ref. Kato  _et al._ (2004). The analytic expressions of these
correlation functions are obtained in Ref. Kato  _et al._ (2004). Plugging in
their results, we find Eq. (9) in the main text.


# CF4J: Collaborative Filtering for Java

Fernando Ortega 111U-tad: Centro Universitario de Tecnología y Arte Digital,
Madrid, Spain Bo Zhu 222Universidad Politécnica de Madrid, Madrid, Spain
333Beijing Institute of Technology, Beijing, China Jesús Bobadilla
††footnotemark:  Antonio Hernando ††footnotemark:

###### Abstract

Recommender Systems (RS) provide a relevant tool to mitigate the information
overload problem. A large number of researchers have published hundreds of
papers to improve different RS features. It is advisable to use RS frameworks
that simplify RS researchers: a) to design and implement recommendations
methods and, b) to speed up the execution time of the experiments. In this
paper, we present CF4J, a Java library designed to carry out Collaborative
Filtering based RS research experiments. CF4J has been designed from
researchers to researchers. It allows: a) RS datasets reading, b) full and
easy access to data and intermediate or final results, c) to extend their main
functionalities, d) to concurrently execute the implemented methods, and e) to
provide a thorough evaluation for the implementations by quality measures. In
summary, CF4J serves as a library specifically designed for the research trial
and error process.

##  1 Introduction

Recommender Systems (RS) provide a relevant tool to mitigate information
overload problem [3, 4]. RS act as a filter that allows to pass the relevant
information to the user and blocks the irrelevant one. RS have been used to
recommend a wide variety of items [12]: movies, books, e-commerce, educational
resources, etc. Collaborative Filtering (CF) is the most popular
implementation of RS [5, 7]. In CF recommendations are computed based on the
ratings that the community of users have made over a set of items. CF can be
sub-classified into [11, 14]:

  1. 1.

Memory based CF: recommendations are computed with methods that act directly
on the rating matrix. Memory based methods usually use similarity metrics to
obtain the distance [13] between two users, or between two items, based on
their corresponding ratings.

  2. 2.

Model based CF: recommendations are computed through a model generated from
the rating matrix. Matrix factorization models [9, 10] currently are the most
popular implementations.

To provide accurate recommendations is one of the major challenges of this big
data field. A large number of researchers around the world have published
papers improving different RS features such as [8]: accuracy, precision,
novelty or reliability. These papers usually compare their proposed methods
against different baselines, in order to highlight their improvement. The
experimentation phase requires to implement the new proposal as well as the
baselines, to execute the comparison using various datasets. Any tool that
simplifies the codification of the recommendation methods and/or speeds up the
execution time of the experiments is desirable for RS research community.

##  2 Problems and Background

CF libraries facilitate the deployment of RS speeding up the implementation
time and reducing the cost of maintenance. Several CF libraries have been
released to perform this task, but the most popular ones are LibRec [2] and
Apache Mahout [1].

LibRec is a GPL-licensed Java library, aiming to solve two classic tasks in
RS, i.e., rating prediction and item ranking. This library has been developed
focusing in the following features: (a) rich algorithms: LibRec has integrated
more than 70 types of recommendations algorithms, (b) modularity: to optimize
its maintenance the library has been divided into data processing, algorithm
training and post-processing modules, and (c) efficient execution
(performance): LibRec has optimized the framework and algorithm
implementations as much as possible.

The Mahout project’s goal is to build an environment for fast creations of
scalable performant machine learning applications. A Mahout-based CF has been
developed and its engine takes users’ preferences for items and returns
estimated preferences for other items. Mahout provides a rich set of
components from which you can construct a customized recommender system
selecting from various algorithms. Mahout is designed to be enterprise-ready;
it’s designed for performance, scalability and flexibility.

In this paper we present CF4J, a new Java library designed to carry out CF
research experiments. LibRec and Mahout are great CF libraries, but they have
been designed for production environments rather than for research
environments. In order to evaluate the capabilities of each library, we are
going to study their suitability in six different software features [6]: (a)
extensibility, (b) performance, (c) efficiency, (d) abstraction, (e)
flexibility, and (d) scalability.

The extensibility is the capability of a software to evolve with the
contributions of third-party developers. Both LibRec, Mahout and CF4J have
been designed thinking in their extensibility and they are free software.
LibRec includes several abstract classes such: AbstractRecommenderSimilarity,
to design new similarity metrics for KNN based CF; AbstractRecommender, to
implement new recommendation methods; or AbstractRecommenderEvaluator, to
build your own quality measures. However, despite the existence of this
abstract classes, their documentation is too poor, and you must dive into the
source code to understand their behavior. Mahout library contains some
interfaces to enable third-party developers to tune the recommendation
algorithms: ItemSimilarity and UserSimilarity interfaces allow the definition
of new similarity metrics between two users and items respectively;
Recommender interface represents the recommendation process of items to users;
and DataModel interface represents a repository of information about users and
their associated preferences for items. The Javadoc of these interfaces are
good, so it is easy to transform Mahout library to your CF requirements. CF4J
allows developers to extend the library through the Partible interfaces. These
interfaces let developers the capability of performing any recommendation step
over the users and items sets of the CF. Furthermore, several abstract classes
have been included in order to facilitate the creation of most popular CF
steps: UsersSimilarities and ItemsSimilarities classes simplify the creation
of new similarity metrics; FactorizationModel class includes the core of CF
factorization methods; and QualityMeasure class facilitates the creation of
new quality measures to get the goodness of a CF. These abstract classes and
interfaces are fully documented both in the Javadoc and the online CF4J’s
tutorial.

Performance measure show us how effective is a software system executing a
task. In this comparison, we will evaluate performance as the facility to
parallelize calculations involved in the recommendation process. LibRec and
Mahout delegates the parallelization to the implementation of each
recommendation algorithm. They do not provide a unique parallelization
framework. Developers that extend these libraries must handle the
parallelization by themselves and implements parallelism using third-party
parallelization tools. However, LibRec has paid great attention to the
efficiency and the built-in algorithms has been optimized as much as possible.
LibRec uses Javas’s ExecutorService class to create a pool of threads based on
the number of available processors. Mahout has also added parallelization to
some of its recommendations methods (e.g. ParallelSGDFactorizer) using
ExecutorService to handle parallelization. CF4J provides a parallelization
framework specifically designed for CF. This framework supplies all required
tools to perform calculations easily in a parallel way over the users and
items sets. All implemented CF4J algorithms use this framework.

The efficiency is the capability of a software system of ensuring the minimum
memory usage. In a CF context, we will analyze how the information about
users, items and ratings are stored in computer memory. LibRec stores rating
information in a sparse matrix provided by the SparseMatrix class. This matrix
stores data using compressed row storage and compressed column storage to
minimize memory consumption. However, some information is duplicated to speed
up the rating information recovery process. Mahout has been designed to run
over different distributed back-ends (Apache Spark is recommended). These
distributed architectures usually replicate data (ratings) among nodes
following the map-reduce paradigm. The replication maximizes the efficiency of
each node and improves fault tolerance of the system. CF4J sacrifices system
efficiency to ensure a proper access to the data. Each rating and its pointers
to the user and item are duplicated on the User and Item classes. The memory
required by the system is double, but the performance of retrieving the
ratings emitted by any user to any item is higher.

The abstraction is a technique for arranging complexity of computer systems.
In a CF library, the abstraction level will be measured as how well the
library models a real RS, that is a set of users that rate a set of items.
LibRec uses low level data structures to store CF data. It provides DataModel
interface to store ratings into a BiMap (a bidirectional map that preserves
the uniqueness of its values as well as that of its keys). Mahout uses
Preference interface to represent ratings. The access to all the ratings is
managed by the DataModel interface; it contains methods to retrieve ratings
using user and item codes. On the other hand, CF4J provides a data model
closer to a real-world RS. It is composed of a full class hierarchy in which
User and Item classes model real users and items. These classes include
several methods to simplify the access to any rating emitted or received by
any user or item.

The flexibility is the capability of a software system to fit with any
unexpected scenario. To measure the degree of flexibility we are trying to ask
the following two questions with each library: (a) How can I retrieve the
similarity between two users? (b) How can I access to the user factors after
factorization process? These questions serve as example of two common needs of
CF research community. In LibRec both questions must be answered as “you can
not do it”. For question (a) the similarity of each pair of users is stored on
the private SymmMatrix attribute of the UserKNNRecommender class. For question
(b) user and item factors are stored on a protected DenseMatrix attribute of
the MatrixFactorizationRecommender. Even if we can access to these non-public
attributes, we need to map the user/item to its row and column in the matrix
to access the data. In Mahout the answer for question (a) is “yes”:
UserSimilarity class stores similarity between each pair of users and this
similarity can be retrieved throughout a public method. However, the answer
for question (b) is “no”: each factorization implementation (e.g.
ALSWRFactorizer class) stores user and item factors in two non-public arrays
and cannot be accessed from outside. In CF4J both question can be answered as
“yes, you can do it easily”. For the question (a) you have a public method in
the TestUser class: it returns the similarity of each user with any user of
the dataset. For the question (b), factorization methods (e.g Pmf class)
include public methods to retrieve the factors of any user.

The scalability is the ability of a software system to accommodate to a growth
to infinity without losing performance. Both LibRec and CF4J have been
designed to run into a standalone machine, so they can only grow vertically
(increment the amount of CPU and RAM of the machine). Mahout’s library runs
over distributed systems (such as Spark), so it can grow vertically and
horizontally (replicate the program to different machines).

Table 1 summarizes the information described in this comparison.

Feature |  CF4J |  LibRec |  Mahout
---|---|---|---
Extensibility |  Includes generic Partible interfaces to implement any custom CF step. It also includes several abstract classes for customize most popular CF steps. |  Includes some abstract classes to personalize recommendation and evaluation steps. Poor documentation. |  Includes abstract classes and interfaces to fully modify the recommendation process according to CF requirements.
Performance |  Provides a parallelization framework specifically designed for CF. It simplifies the coding of parallelized algorithms. |  Parallelization is handled by each built-in algorithm. It does not provide any facility to extends the library using parallel algorithms. |  Parallelization is handled by each built-in algorithm. It does not provide any facility to extends the library using parallel algorithms.
Efficiency |  Ratings information is duplicated between users and items to improve library’s performance. |  Data is stored in a sparse matrix to minimize memory consumption. |  The library is capable to replicate data over different distributed back-ends, maximizing the efficiency of each one.
Abstraction |  Provides a full class hierarchy that contains a high-level representation of the dataset through User and Item classes. |  Ratings are stored in a low level BiMap data structure. Ratings must be retrieved using user and item codes. |  DataModel interface manages rating retrieval. Ratings are modeled thorough the Preference class.
Flexibility |  Easy access to any intermediate value generated to compute recommendation. |  Null access to any intermediate value generated to compute recommendation. |  Very limited access to any intermediate value generated to compute recommendation.
Scalability |  Vertical scalability only |  Vertical scalability only |  Both horizontal and vertical scalability
Table 1: Comparison between CF4J, LibRec and Mahout CF libraries based on
different software features.

Production and research environments usually have different (and opposite)
needs. Mainly, we have the need to maximize performance and efficiency in
order to reduce computational costs. However, any CF library designed for
research environments must satisfy the following requirements:

  * •

Extensibility: new ideas must be compared with state-of-the-art baselines to
highlight their improvement. A proper CF research-library must be extendable
for new implementations of other researchers. The extension processes should
be as simple as possible. Open source projects are recommendable to warranty
the library’s evolution.

  * •

Performance: both model based CF and memory based CF require a high
computational cost to obtain recommendations. This cost can be reduced by
using parallel computing. Parallelization is usually a complex task in
programming. A proper CF research-library should facilitate the
parallelization of the algorithms.

  * •

Efficiency: do not waste computer memory is desirable for any software.
However, in a research environment, to make easy dataset information retrieval
is more important than do not waste computer memory. It is necessary to find a
tradeoff between memory consumption and library simplicity.

  * •

Abstraction: the essential information required by CF is the user set, the
item set and ratings cast from users to items. This information is usually
provided to the researchers as text files with lines containing the triple
¡user, item, rating¿. A proper CF research-library should be capable to load
these files and to create a data model that represents real world interactions
between users and items.

  * •

Flexibility: some CF publications are disruptive. These types of publications
require to modify crucial components / steps of the traditional CF algorithm.
A proper CF research-library must provide full access to data structures,
allowing researchers to replace or modify all the components and stages of the
CF methods.

  * •

Scalability: public CF datasets contain from hundreds of thousands of ratings
to hundreds of millions of ratings. Nowadays, any mid-range computer has
enough computational power and memory capacity to store these datasets and to
run any recommendation method in a few hours. Horizontal scalability is not
required in the vast majority of CF research.

Feature | CF4J | LibRec | Mahout
---|---|---|---
Extensibility | ***** | ***** | *****
Performance | ***** | ** | **
Efficiency | * | **** | *****
Abstraction | ***** | * | **
Flexibility | ***** | * | **
Scalability | * | * | *****
Table 2: Suitability of each CF library for a research environment.

Table 2 shows the suitability of each library for a research environment. Each
feature has been scored from one to five stars. According to this table, CF4J
is the most suitable CF library for research environments. CF4J has been
designed following the extensibility, performance, abstraction and flexibility
majors; for it, scalability and efficiency have been sacrificed. In turn,
LibRec is a great library if you need a fast RS deployment due to the wide
variety of recommendation methods that provides, and Mahout is the best
library if you need a high scalable RS.

##  3 Software Framework

The CF4J library and its documentation is available at its GitHub repository:
https://github.com/ferortega/cf4j

###  3.1 Software Architecture

CF4J has been designed following the packages structure shown in Figure 1.
This structure has been created based on CF classification. The root of the
package tree is the cf4j package; it contains the main classes to load, read
and manipulate the CF data model. Kernel class loads the rating data from a
text file and creates the required instances of User and Item to build de data
model. The model package includes the implementations of model based CF
methods. In this version, we have included several matrix factorization based
CF implementations; other models will be easily added under this package. The
knn package contains all the required objects to compute recommendations using
memory based CF. It includes both user-to-user (userToUser package) and item-
to-item (itemToItem package) approaches. Different similarity metrics (Pearson
correlation, cosine, MSD, etc.), aggregation approaches (mean, weighted mean
and deviation from mean) and neighborhoods creation algorithms have been added
to the similarities, aggregationApproaches and neighbors sub-packages
respectively. Finally, the qualityMeasures package contains different measures
to check the goodness of the predictions (MAE and Coverage) and the
recommendations (Precision and Recall).

Figure 1: CF4J package architecture.

###  3.2 Software Functionalities

CF4J has been designed to cover the CF research community needs. The main
functionalities provided with the library are:

  * •

Data loading from third party text file based datasets. CF4J reads sparse
ratings matrices from text files and it creates a full class hierarchy to
store this information. CF4J also divides users and items into training and
tests user sets and training and test item sets.

  * •

In memory data storage. Information about users, items and ratings is stored
in memory using efficient data structures that make it easy to retrieve any
dataset information. Several statistical data aggregations (rating average,
rating standard deviation, etc.) are also precomputed to speed up future
computations.

  * •

Extensible pipeline. CF algorithms are usually composed of several sequential
steps. Each of these steps generates an output that is used for the following
step. CF4J includes several maps to store objects generated for any step that
can be retrieved by the following step.

  * •

Fast execution. CF4J includes the Processor class to simplify the
parallelizable calculations. Implementing Partible interface, CF4J
concurrently executes any process over users, test users, items or test items
arrays.

  * •

Model-based methods support, implementing matrix factorization machine
learning solutions.

  * •

Memory-based methods support, implementing the K Nearest Neighbors approach,
both in its user to user and item to item variations.

  * •

Quality measures support: both prediction and recommendation ones.

##  4 Implementation and Empirical Results

CF4J is a Java library designed to carry out experiments. Its installation is
available from most popular Java repositories: Maven, Gradle and SBT. A jar
file has also been packetized to be used in projects that do not use these
repositories. Once the library is imported to the Java project, all classes
and methods described in Section 3 are available to be used.

Experiments are easily encoded using Kernel and Processor classes. Kernel
class manages all the information related with the RS. This class implements
the singleton design pattern and it contains methods to load and manipulate
ratings. This class also splits the users and items sets into test and
training sets. Processor class handles the parallel execution of Partible
implementations. A Partible is an interface that transform any CF algorithm
steps to be parallelized. Parallelization is carried out over the users, test
users, items or test items sets. Most of the provided example implementations
have been encoded using the Partible interfaces.

Once a novel proposed research method has been implemented using CF4J, the
typical experiment steps are:

  1. 1.

Load ratings from a text file.

  2. 2.

For each tested method:

    1. (a)

Compute predictions and recommendations.

    2. (b)

Check the quality of the predictions and recommendations using quality
measures.

  3. 3.

Show results and analyze them.

Using PrintableQualityMeasure class you can store and print results for
different CF based implementations comparison. The output of the script is
exportable to any spreadsheet, and it is possible to obtain different charts
summarizing results. Figure 2 contains: a) the output of a script comparing
two similarity metrics, and b) the generated chart using a spreadsheet
processor.

Figure 2: Output of CF4J and transformation to a chart using LibreOffice
spreadsheets.

##  5 Illustrative Examples

In this section we are going to explain, step by step, a representative
example of CF experimentation using CF4J. In this example we compare MAE’s
quality measure for different number of neighbors, using Pearson Correlation
and JMSD as similarity metrics. Listing 1 contains the full code of the
example.

Lines 01-10 will set up the environment to perform the experiment. Lines 01-05
load ratings from a text file and define parameters to split dataset into
training and test sets. In this example we are using MovieLens dataset, but
any other ratings based dataset can be used. Line 07 defines the similarity
metrics (COR and JMSD) used in this experiment. Line 08 defines the number of
neighbors with which each similarity metric is going to be evaluated. Line 10
creates an instance of PrintableQualityMeasure class to store MAE results.

Lines 12-36 are the core of the experiment. Each combination of the parameters
(each similarity metric for each number of neighbors) are tested to obtain its
associated error. Line 17 and line 20 compute the similarity between of each
test user with any user of the RS. The usage of Person Correlation or JMSD
similarity is defined by the ‘sm’ variable. Line 27 establishes the neighbors
of each test user. Line 30 calculates predictions, aggregating the neighbors’
ratings by using deviation from mean. Lines 33-34 obtain the error of
predictions using the MAE quality measure. They also store the MAE values to
be retrieved in the future.

Finally, we print results; line 39 prints, by using the standard output, the
experiment results.

Listing 1: CF experiment encoded with CF4J.

⬇

1String dbPath = ”datasets/movielens/ratings.dat”;

2double testUsers = 0.20; // 20% of test users

3double testItems = 0.20; // 20% of test items

4

5Kernel.getInstance().open(dbPath, testUsers, testItems, ”::”);

6

7String [] similarityMetrics = {”COR”, ”JMSD”};

8int [] numberOfNeighbors = {50, 100, 150, 200, 250, 300, 350, 400};

9

10PrintableQualityMeasure mae = new cf4j.utils.PrintableQualityMeasure(”MAE”,
numberOfNeighbors, similarityMetrics);

11

12// For each similarity metric

13for (String sm : similarityMetrics) {

14

15 // Compute similarity

16 if (sm.equals(”COR”)) {

17 Processor.getInstance().testUsersProcess(new
cf4j.knn.userToUser.similarities.MetricCorrelation());

18 }

19 else if (sm.equals(”JMSD”)) {

20 Processor.getInstance().testUsersProcess(new
cf4j.knn.userToUser.similarities.MetricJMSD());

21 }

22

23 // For each value of k

24 for (int k : numberOfNeighbors) {

25

26 // Find the neighbors

27 Processor.getInstance().testUsersProcess(new
cf4j.knn.userToUser.neighbors.Neighbors(k));

28

29 // Compute predictions using DFM

30 Processor.getInstance().testUsersProcess(new
cf4j.knn.userToUser.aggregationApproaches.DeviationFromMean());

31

32 // Compute MAE

33 Processor.getInstance().testUsersProcess(new cf4j.qualityMeasures.MAE());

34 mae.putError(k, sm, Kernel.gi().getQualityMeasure(”MAE”));

35 }

36}

37

38// Print the results

39mae.print();

This example has been added to source code at the class examples.
PaperExample. Furthermore, the online documentation contains other examples of
the CF4J usage. We have included examples to: a) compare MAE, Coverage,
Precision, Recall and F1 for several similarity metrics in knn based CF, b)
compare the MAE of user-to-user and item-to-item knn based CF, and c) compare
the MAE of knn based CF vs matrix factorization based CF.

##  6 Conclusions

CF4J provides an object-oriented Java framework useful for RS CF researchers.
It has been created to facilitate the experimentation of new CF based
recommendation algorithms. This library has been designed for research; its
flexibility allows researchers to modify any CF component or step.
Additionally, multiple published methods have been included to be used as
baselines. A deep comparison between CF4J and most popular CF libraries
(Librec and Mahout) demonstrates the superiority of CF4J for the research
trial and test processes. CF4J has been designed to simplify experiments
codification. The library is capable to load sparse ratings matrix from text
files into a full class hierarchy. It also split users and items into training
and test sets to perform cross-validation experiments. CF4J speeds up
execution by concurrently running experiments; all the library’s provided
methods can execute in parallel. Finally, most popular quality measures have
been included into the library to compare results of novel algorithms against
baselines.

## References

  * [1] Apache mahout.  https://mahout.apache.org/users/algorithms/recommender-overview.html.  Accessed: December 14th, 2017.
  * [2] Librec.  https://www.librec.net/.  Accessed: December 14th, 2017.
  * [3] Gediminas Adomavicius and Alexander Tuzhilin.  Toward the next generation of recommender systems: A survey of the state-of-the-art and possible extensions.  IEEE transactions on knowledge and data engineering, 17(6):734–749, 2005.
  * [4] Gediminas Adomavicius and Alexander Tuzhilin.  Context-aware recommender systems.  In Recommender systems handbook, pages 217–253. Springer, 2010.
  * [5] Jesús Bobadilla, Fernando Ortega, Antonio Hernando, and Abraham Gutiérrez.  Recommender systems survey.  Knowledge-based systems, 46:109–132, 2013.
  * [6] G. Booch.  Object oriented analysis & design with application.  Pearson Education India, 2006.
  * [7] Jonathan L Herlocker, Joseph A Konstan, Al Borchers, and John Riedl.  An algorithmic framework for performing collaborative filtering.  In Proceedings of the 22nd annual international ACM SIGIR conference on Research and development in information retrieval, pages 230–237, 1999.
  * [8] Jonathan L Herlocker, Joseph A Konstan, Loren G Terveen, and John T Riedl.  Evaluating collaborative filtering recommender systems.  ACM Transactions on Information Systems (TOIS), 22(1):5–53, 2004.
  * [9] Antonio Hernando, Jesús Bobadilla, and Fernando Ortega.  A non negative matrix factorization for collaborative filtering recommender systems based on a bayesian probabilistic model.  Knowledge-Based Systems, 97:188–202, 2016.
  * [10] Yehuda Koren, Robert Bell, and Chris Volinsky.  Matrix factorization techniques for recommender systems.  Computer, 42(8):30–37, 2009.
  * [11] Michael J Pazzani.  A framework for collaborative, content-based and demographic filtering.  Artificial intelligence review, 13:393–408, 1999.
  * [12] Francesco Ricci, Lior Rokach, and Bracha Shapira.  Introduction to recommender systems handbook.  In Recommender systems handbook, pages 1–35. Springer, 2010.
  * [13] Badrul Sarwar, George Karypis, Joseph Konstan, and John Riedl.  Item-based collaborative filtering recommendation algorithms.  In Proceedings of the 10th international conference on World Wide Web, pages 285–295, 2001.
  * [14] Xiaoyuan Su and Taghi M Khoshgoftaar.  A survey of collaborative filtering techniques.  Advances in artificial intelligence, 2009, 2009.