# Stochastic thermodynamics of all-to-all interacting many-body systems

Tim Herpich  Electronic Mail<EMAIL_ADDRESS>Tommaso Cossetto  Gianmaria
Falasco  Massimiliano Esposito  Electronic Mail<EMAIL_ADDRESS>Complex Systems and Statistical Mechanics, Department of Physics and Materials
Science, University of Luxembourg, L-1511 Luxembourg, Luxembourg

(September 3, 2024)

###### Abstract

We provide a stochastic thermodynamic description across scales for $N$
identical units with all-to-all interactions that are driven away from
equilibrium by different reservoirs and external forces. We start at the
microscopic level with Poisson rates describing transitions between many-body
states. We then identify an exact coarse graining leading to a mesoscopic
description in terms of Poisson transitions between system occupations. We
proceed studying macroscopic fluctuations using the Martin-Siggia-Rose
formalism and large deviation theory. In the macroscopic limit
($N\leavevmode\nobreak\ \to\leavevmode\nobreak\ \infty$), we derive the exact
nonlinear (mean-field) rate equation describing the deterministic dynamics of
the most likely occupations. We identify the scaling of the energetics and
kinetics ensuring thermodynamic consistency (including the detailed
fluctuation theorem) across microscopic, mesoscopic and macroscopic scales.
The conceptually different nature of the “Shannon entropy” (and of the ensuing
stochastic thermodynamics) at different scales is also outlined. Macroscopic
fluctuations are calculated semi-analytically in an out-of-equilibrium Ising
model. Our work provides a powerful framework to study thermodynamics of
nonequilibrium phase transitions.

##  I Introduction

Interacting many body systems can give rise to a very rich variety of emergent
behaviors such as phase transitions. At equilibrium, their thermodynamic
properties have been the object of intensive studies and are nowadays well
understood Stanley (1971); Goldenfeld (1992); Yeomans (1992); Landau and
Lifshitz (1994), see also Kadanoff (2009) for a more philosophical
perspective. When driven out-of-equilibrium, these systems are known to give
rise to complex dynamical behaviors Schulman (1980); Gaveau and Schulman
(1987); Schmittmann and Zia (1995); Bouchaud  _et al._ (1997); Ódor (2008);
Acebrón  _et al._ (2005); Cleuren and den Broeck (2001); Garrido  _et al._
(1987); Blote  _et al._ (1990); Ruijgrok and Tjon (1973). While most of the
works are focused on their ensemble averaged description, in recent years
progress was also made in characterizing their fluctuations Garrahan  _et al._
(2009); Vaikuntanathan  _et al._ (2014); Marcuzzi  _et al._ (2014); Bertini
_et al._ (2015); Jack and Sollich (2010). However, little is known about their
thermodynamic description. For instance, thermodynamics of nonequilibrium
phase transitions started to be explored only recently Herpich  _et al._
(2018); Suñé and Imparato (2019); Herpich and Esposito (2019); Vroylandt  _et
al._ (2017); Golubeva and Imparato (2013, 2012); Imparato (2015); Noa  _et
al._ (2019); Sasa (2015); Noa  _et al._ (2019); Tomé and de Oliveira (2012);
Crochik and Tomé (2005); Zhang and Barato (2016); Crosato  _et al._ (2018).
There is a pressing need to develop methodologies to study thermodynamic
quantities such as heat work and dissipation, not only at the average but also
at the fluctuation level. To do so one has to start from stochastic
thermodynamics that has proven instrumental to systematically infer the
thermodynamics of small systems that can be driven arbitrarily far from
equilibrium Seifert (2012); Van den Broeck and Esposito (2015); Sekimoto
(2010); Zhang  _et al._ (2012); Ge  _et al._ (2012); Jarzynski (2011). This
theory consistently builds thermodynamics on top of a Markov dynamics (e.g.
master equations Esposito and Van den Broeck (2010) or Fokker-Planck equations
Van den Broeck and Esposito (2010)) describing open systems interacting with
their surrounding. Its predictions have been experimentally validated in a
broad range of fields ranging from electronics to single molecules and
Brownian particles Pekola  _et al._ (2013); Ciliberto (2017). It has been
particularly successful in studying the performance of small energy converters
operating far-from-equilibrium and their power-efficiency trade-off Seifert
(2012); Esposito  _et al._ (2009); Verley  _et al._ (2014a); Polettini and
Esposito (2017); Shiraishi  _et al._ (2016); Pietzonka and Seifert (2018).
Until now, most of the focus has been on systems with finite phase space or
few particle systems. However there are exceptions. Interacting systems have
started to be considered in the context of energy conversion to asses whether
they can trigger synergies in large ensembles of interacting energy
converters. Beside few works such as Herpich  _et al._ (2018); Suñé and
Imparato (2019), most other studies are restricted to mean-field treatments
Herpich and Esposito (2019); Vroylandt  _et al._ (2017); Golubeva and Imparato
(2012, 2013); Imparato (2015); Golubeva  _et al._ (2013); Vroylandt  _et al._
(2019). Another exception are chemical reaction networks which provide an
interesting class of interacting systems. Indeed, while molecules in ideal
solution are by definition noninteracting from an energetic standpoint, the
stoichiometry of non-unimolecular reactions creates correlations amongst
molecular species which generate entropic interactions. In the macroscopic
limit, the mean field dynamics is exact and nonlinear Nicolis and Prigogine
(1977); Ge and Qian (2011); Anderson and Kurtz (2015) and can give rise to all
sorts of complex behaviors Epstein and Showalter (1996). The thermodynamics of
chemical reaction networks has started to raise some attention in recent years
Gaspard (2004); Polettini  _et al._ (2015); Rao and Esposito (2016, 2018a);
Lazarescu  _et al._ (2019).

The main achievement of this paper is to provide a consistent nonequilibrium
thermodynamic description across scales of many body systems with all-to-all
interactions. We do so by considering $N$ identical units with all-to-all (or
infinite range) interactions. Each unit is composed of $q$ discrete states and
undergoes transitions caused by one or more reservoirs. It may also be driven
by an external force. The thermodynamics of this open many-body system is
formulated at the ensemble averaged and fluctuating level, for finite $N$ as
well as in the macroscopic limit $N\to\infty$.

At the _microscopic level_ , the system is characterized by microstates which
correspond to the many-body states (i.e. they define the state of each of the
units). Poisson rates describe the transitions between the microstates
triggered by the reservoirs. These rates satisfy local detail balance, i.e.
their log-ratio is the entropy change in the reservoir caused by the
transition Rao and Esposito (2018b). It implicitly assumes that the system is
weakly coupled to reservoirs which instantaneously relax back to equilibrium
after an exchange with the system. By linking the stochastic dynamics with the
physics, this crucial property ensures a consistent nonequilibrium
thermodynamics description of the system, in particular a detailed fluctuation
theorem and an ensuing second law at the ensemble averaged level. The entropy
of a state is given by minus the logarithm of the probability to find the
system in that state and the ensemble averaged entropy is the corresponding
Shannon entropy.

Because we assume all units to be identical in the way they interact with each
other and with the reservoirs, we show that the _microscopic_ stochastic
dynamics can be exactly coarse grained to a _mesoscopic level_ , where each
system state specifies the unit occupations (i.e. the exact number of units
which are in each of the unit states). The mesoscopic rates describing
transition between occupations satisfy a local detailed balance. At this
level, the entropy of a state is given by minus the logarithm of the
probability to find the system in that state plus the internal entropy given
by the logarithm of the number of microstates inside a mesostate, reflecting
the fact that the units are energetically indistinguishable. We demonstrate
that stochastic thermodynamics is invariant under this exact coarse-graining
of the stochastic dynamics, provided one considers initial conditions which
are uniform within each mesostate, or for systems in stationary states.

We then consider the _macroscopic limit_ ($N\to\infty$). Using a path integral
representation of the stochastic dynamics (Martin-Siggia-Rose formalism), we
identify the scaling in system size of the rates and of the energy that is
necessary to ensure that the macroscopic fluctuations (i.e. the fluctuations
that scale exponentially with $N$) satisfy a detailed fluctuation theorem and
are thus thermodynamically consistent. We show via the path-integral
representation that the stochastic dynamics exactly reduces to a mean-field
rate equation with nonlinear rates governing the evolution of the
deterministic variables which correspond to the most likely values of the
occupation of each unit state. Remarkably, the nonlinear rates still satisfy
local detailed balance and the entropy of each deterministic occupation is
given by minus their logarithm. The entropy is thus a Shannon entropy for
deterministic variables exclusively arising from the entropy inside the
mesostates and not from the probability distribution to be on a mesostates.
Indeed, this latter narrows down around its single or multiple (in case of
phase transition) most likely values and gives rise to a vanishing stochastic
entropy. We finally use our methodology to calculate macroscopic fluctuations
in a semi-analytically solvable Ising model in contact with two reservoirs and
displaying a nonequilibrium phase transition.

The plan of the paper is as follows. First, in Sec. II, the many-body model is
introduced and the stochastic dynamics is formulated. Moreover, the exact
coarse-graining scheme is presented and the asymptotic mean-field equations
are derived. Next, in Sec. III, using the formalism of stochastic
thermodynamics and Martin-Siggia-Rose, the fluctuating thermodynamic
quantities are formulated at different scales and the conditions under which
they are preserved across these scales are identified. These theoretical
results are illustrated via a semi-analytically solvable Ising model. We
conclude with a summary and perspectives in Sec. VI.

##  II Stochastic Dynamics

###  II.1 Microscopic Description

We consider a system that consists of $N$ all-to-all interacting identical and
classical units that consist of $q$ states $i$ with energies
$\epsilon_{i}(\lambda_{t})$ that are varying in time according to a known
protocol $\lambda_{t}$ of an external driving. The system is coupled with
multiple heat reservoirs $\nu=1,2,\leavevmode\nobreak\
\ldots\leavevmode\nobreak\ ,L$ at inverse temperatures $\beta^{(\nu)}$. Each
unit is assumed to be fully connected, _i.e._ any state of a given unit can be
reached within a finite number of steps from all other states of that unit, so
that the global system is irreducible. Moreover, we suppose that all units are
subjected to generic nonconservative forces $f_{ij}^{(\nu)}$. Depending on
whether a transition is aligned with or acting against the nonconservative
force, the latter fosters or represses the transition from state $j$ to $i$.
For generality, the force is assumed to be different depending on which heat
reservoir $\nu$ the system is exchanging energy with during the transition
from $j$ to $i$. Until explicitly states otherwise, we will take $N$ to be
finite in the following.

The many-body system is unambiguously characterized by a microstate

$\displaystyle\alpha=(\alpha_{1},\ldots,\alpha_{i},\ldots,\alpha_{N}),\quad\alpha_{i}=1,2,\ldots,q.$
(1)

The system energy consists of the state occupation of the units and the
interactions between them. For all-to-all interactions, we readily determine
the energy of the system in a microstate $\alpha$ as follows,

$\displaystyle e_{\alpha}(\bm{\lambda}_{t})$
$\displaystyle=\sum\limits_{i=1}^{q}\Big{\\{}N_{i}(\alpha)\,\epsilon_{i}(\lambda_{t})+\frac{u_{i}(\lambda^{\prime}_{t})}{2N}\,N_{i}(\alpha)\big{[}N_{i}(\alpha)-1\big{]}+\sum\limits_{j<i}\frac{u_{ij}(\lambda^{\prime}_{t})}{N}N_{i}(\alpha)\,N_{j}(\alpha)\Big{\\}},$
(2)

where $u_{i}(\lambda^{\prime}_{t})/N$ and $u_{ij}(\lambda^{\prime}_{t})/N$
denote the pair potential of units occupying the same or different single-unit
states, respectively. These interactions can be tuned by an external driving
according to a known protocol $\lambda^{\prime}_{t}$, hence
$\bm{\lambda}_{t}\leavevmode\nobreak\ =\leavevmode\nobreak\
\big{(}\lambda_{t},\lambda^{\prime}_{t}\big{)}^{\top}$. Moreover,
$N_{i}(\alpha)$ refers to the number of units $N_{i}$ occupying the single-
unit state $i$ for a given microstate $\alpha$.

The stochastic jump process is governed by an irreducible Markovian master
equation which describes the time evolution of the microscopic probability
$p_{\alpha}$ for the system to be in the microstate $\alpha$ as follows,

$\displaystyle\partial_{t}p_{\alpha}(t)=\sum\limits_{\alpha^{\prime}}w_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})\,p_{\alpha^{\prime}}(t)\,,$
(3)

with the microscopic rates $w_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})$ for
transitions from $\alpha^{\prime}$ to $\alpha$ that in general depend on the
current value of the driving parameter $\bm{\lambda}_{t}$. We note that
probability conservation is ensured by the stochastic property of the
transition rate matrix,
$\sum_{\alpha}w_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})=0$. The transition
from $\alpha^{\prime}$ to $\alpha$ is induced by one of the $L$ heat
reservoirs, thus

$\displaystyle
w_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})=\sum\limits_{\nu=1}^{L}w^{(\nu)}_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t}).$
(4)

Here, for simplicity we assume that the transition rates are additive in the
reservoirs $\nu$. A more general treatment can be made following the procedure
described in Ref. Rao and Esposito (2018b). The microscopic transition rates
that specify the heat reservoir satisfy the microscopic local detailed balance
condition separately,

$\displaystyle\frac{w^{(\nu)}_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})}{w^{(\nu)}_{\alpha^{\prime}\alpha}(\bm{\lambda}_{t})}=\exp\Big{\\{}-\beta^{(\nu)}\left[e_{\alpha}(\bm{\lambda}_{t})-e_{\alpha^{\prime}}(\bm{\lambda}_{t})-\bm{f}_{\alpha\alpha^{\prime}}^{(\nu)}\right]\Big{\\}},$
(5)

which in turn ensures the thermodynamic consistency of the system. Here,
$\bm{f}^{(\nu)}_{\alpha\alpha^{\prime}}$ is the element of the nonconservative
force vector $\bm{f}^{(\nu)}$ that is equal to $f_{ij}^{(\nu)}$, if the
microscopic transition from $\alpha^{\prime}\to\alpha$ corresponds to a
single-unit transition from $j\to i$. If the transition rates are kept
constant, $\bm{\lambda}_{t}=\bm{\lambda}$, the dynamics will relax into a
unique stationary state, $\partial_{t}p_{\alpha}^{s}(\bm{\lambda})=0$. If
furthermore all heat reservoirs have the same inverse temperature,
$\beta^{(\nu)}=\beta\;\forall\nu$, and the nonconservative forces vanish,
$\bm{f}^{(\nu)}=0\;\forall\nu$, the stationary distribution coincides with the
equilibrium one which satisfies the microscopic detailed balance condition,

$\displaystyle
w_{\alpha\alpha^{\prime}}(\bm{\lambda})\,p_{\alpha^{\prime}}^{eq}(\bm{\lambda})=w_{\alpha^{\prime}\alpha}(\bm{\lambda})\,p_{\alpha}^{eq}(\bm{\lambda}).$
(6)

The local detailed balance (5) implies that the microscopic equilibrium
distribution assumes the canonical form,

$\displaystyle p^{eq}_{\alpha}(\bm{\lambda})$
$\displaystyle=\exp\big{\\{}-\beta\left[e_{\alpha}(\bm{\lambda})-a^{eq}(\bm{\lambda})\right]\big{\\}}\,,$
(7) with the microscopic equilibrium free energy $\displaystyle
a^{eq}(\bm{\lambda})$
$\displaystyle=-\frac{1}{\beta}\,\ln\,\sum\limits_{\alpha}\exp\big{[}-\beta
e_{\alpha}(\bm{\lambda})\big{]}\,.$ (8)

###  II.2 Mesoscopic Description

The microscopic state space grows exponentially with the number of units,
$||\alpha||=q^{N}$. Yet, the complexity of the system can be significantly
reduced. First, we note that due to the all-to-all interactions, there are
equi-energetic microstates that are characterized by the same values for the
occupation numbers $N_{i}$. Next, we assume that the units are not only
indistinguishable energetically [asymmetric part of the microscopic transition
rates (5)] but also kinetically [symmetric part of the microscopic transition
rates (4)] because they are all coupled in the same way to the reservoirs. As
a result, the microscopic transition rates do not depend on the detailed pair
of microstates that they connect but only on the pair of mesostate
$\bm{N}\leavevmode\nobreak\ \equiv\leavevmode\nobreak\
(N_{1},N_{2},\leavevmode\nobreak\ \ldots\leavevmode\nobreak\ ,N_{q})$ that
they connect.

Consequentially, the microscopic dynamics can be marginalized into a
mesoscopic one, where the mesostate $\bm{N}$ now identifies the state of the
system. We denote by $\alpha_{{}_{\bm{N}}}$ the equienergetic microstates
$\alpha$ inside a mesostate $\bm{N}$, that is microstates for which the
relation

$\displaystyle
e_{\alpha_{{}_{\bm{N}}}}(\bm{\lambda}_{t})=E_{\bm{N}}(\bm{\lambda}_{t}),$ (9)

holds. The number $\Omega_{\bm{N}}$ of microstates which belong to a mesostate
is given by

$\displaystyle\Omega_{\bm{N}}=\binom{N}{N_{1}}\binom{N-N_{1}}{N_{2}}\cdots\binom{N-N_{1}-\ldots-
N_{q-1}}{N_{q}}=\frac{N!}{\prod\limits_{i=1}^{q}N_{i}!}\,.$ (10)

We introduce the mesoscopic probability to observe the mesostate $\bm{N}$

$\displaystyle P_{\bm{N}}(t)$
$\displaystyle\equiv\sum\limits_{\alpha_{{}_{\bm{N}}}}\,p_{\alpha_{{}_{\bm{N}}}}(t)\,.$
(11)

The conditional probability to find the system in a microstate
$\alpha_{{}_{\bm{N}}}$ that belongs to that mesostate reads

$\displaystyle\mathbb{P}_{\alpha_{{}_{\bm{N}}}}(t)=\frac{p_{\alpha_{{}_{\bm{N}}}}(t)}{P_{\bm{N}}(t)}.$
(12)

Probability normalization implies that

$\displaystyle\sum_{\alpha_{{}_{\bm{N}}}}\mathbb{P}_{\alpha_{{}_{\bm{N}}}}(t)=1.$
(13)

With Eqs. (9), (11) and (13) the microscopic master equation (3) can be
exactly coarse-grained as follows,

$\displaystyle\partial_{t}P_{\bm{N}}(t)$
$\displaystyle=\sum\limits_{\bm{N}^{\prime}}\sum\limits_{\alpha_{{}_{\bm{N}}}}\sum\limits_{\alpha^{\prime}_{{}_{\bm{N}^{\prime}}}}w_{\alpha_{{}_{\bm{N}}},\alpha^{\prime}_{{}_{\bm{N}^{\prime}}}}(\bm{\lambda}_{t})\;\,\mathbb{P}_{\alpha^{\prime}_{{}_{\bm{N}^{\prime}}}}\\!(t)\;P_{\bm{N}^{\prime}}(t)=\sum\limits_{\bm{N}^{\prime}}W_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda}_{t})\;P_{\bm{N}^{\prime}}(t)\,,$
(14)

with the mesoscopic transition rates
$W_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda}_{t})=\Omega_{\bm{N},\bm{N}^{\prime}}\;w_{{}_{\bm{N}\bm{N}^{\prime}}}(\bm{\lambda}_{t})$.
The quantity $\Omega_{\bm{N},\bm{N}^{\prime}}$ takes into account that only
those microstates $\alpha_{{}_{\bm{N}}}$ and
$\alpha^{\prime}_{{}_{\bm{N}^{\prime}}}$ contribute to the sum in Eq. (14)
which are connected to each other. This amounts to determine how many
microstates $\alpha$ belong to the mesostate $\bm{N}$ under the constraint
that they are connected to microstates $\alpha^{\prime}$ belonging to the
mesostate $\bm{N}^{\prime}$. The combinatorial problem is readily solved by
noting that the occupation number that is decremented during the transition
corresponds to the wanted quantity, _i.e._

$\displaystyle\Omega_{\bm{N},\bm{N}^{\prime}}$
$\displaystyle=\sum_{i=1}^{q}N^{\prime}_{i}\,\delta_{N^{\prime}_{i},N_{i}+1}\,,$
(15)

where $N_{i}+1$ is understood as $(N_{i}+1)\text{ mod }q$. It is easy to
verify that the stochastic property of the transition rate matrix is preserved
by the coarse-graining,
$\sum_{\bm{N}}W_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda}_{t})=0$. The mesoscopic
transition rates are still consisting of multiple contributions due to the
different heat reservoirs,

$\displaystyle
W_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda}_{t})=\sum\limits_{\nu=1}^{L}W_{\bm{N}\bm{N}^{\prime}}^{(\nu)}(\bm{\lambda}_{t}),$
(16)

that separately preserve the microscopic local detailed balance relation (5)
at the mesoscopic level,

$\displaystyle\frac{W_{\bm{N}\bm{N}^{\prime}}^{(\nu)}(\bm{\lambda}_{t})}{W_{\bm{N}^{\prime}\bm{N}}^{(\nu)}(\bm{\lambda}_{t})}=\exp\Big{\\{}-\beta^{(\nu)}\left[A^{(\nu)}_{\bm{N}}(\bm{\lambda}_{t})-A^{(\nu)}_{\bm{N}^{\prime}}(\bm{\lambda}_{t})-\bm{f}^{(\nu)}_{\bm{N},\bm{N}^{\prime}}\,\right]\Big{\\}},$
(17)

with the notation $\bm{f}^{(\nu)}_{\bm{N},\bm{N}^{\prime}}$ that is defined as
$\bm{f}^{(\nu)}_{\alpha,\alpha^{\prime}}$ in Eq. (5). Here, we introduced the
free energy of a mesostate

$\displaystyle
A^{(\nu)}_{\bm{N}}(\bm{\lambda}_{t})=E_{\bm{N}}(\bm{\lambda}_{t})-\frac{1}{\beta^{(\nu)}}\,S^{int}_{\bm{N}},$
(18)

and used the Boltzmann entropy

$\displaystyle S^{int}_{\bm{N}}=\ln\Omega_{\bm{N}}\,,$ (19)

along with the relation

$\displaystyle\frac{\Omega_{\bm{N}}}{\Omega_{\bm{N}^{\prime}}}=\frac{\Omega_{\bm{N},\bm{N}^{\prime}}}{\Omega_{\bm{N}^{\prime},\bm{N}}},$
(20)

which can be seen by using Eqs. (10) and (15). We remark that the dynamically
exact coarse-graining of the microscopic dynamics towards a mesoscopic one has
already been identified for and applied to an all-to-all interacting Ising
model in Ref. Ruijgrok and Tjon (1973).

If the transition rates are kept constant, $\bm{\lambda}_{t}=\bm{\lambda}$,
the dynamics will reach a unique stationary state,
$\partial_{t}P_{\bm{N}}^{s}(\bm{\lambda})=0$. If furthermore all heat
reservoirs have the same inverse temperature,
$\beta^{(\nu)}=\beta\;\forall\nu$, and the nonconservative forces vanish,
$\bm{f}^{(\nu)}=0\;\forall\nu$, the stationary distribution coincides with the
equilibrium one which satisfies the mesoscopic detailed balance condition,

$\displaystyle
W_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda})\,P_{\bm{N}^{\prime}}^{eq}(\bm{\lambda})=W_{\bm{N}^{\prime}\bm{N}}(\bm{\lambda})\,P_{\bm{N}}^{eq}(\bm{\lambda}),$
(21)

and, because of Eq. (17), assumes the canonical form,

$\displaystyle
P^{eq}_{\bm{N}}(\bm{\lambda})=\exp\big{\\{}-\beta\left[A_{\bm{N}}(\lambda)-A^{eq}(\bm{\lambda})\right]\big{\\}},$
(22)

with the mesoscopic equilibrium free energy

$\displaystyle
A^{eq}(\bm{\lambda})=-\frac{1}{\beta}\ln\sum\limits_{\bm{N}}\exp\big{[}-\beta
A_{\bm{N}}(\bm{\lambda})\big{]}\,.$ (23)

The marginalization of the equienergetic microstates significantly reduces the
complexity of the system since the mesoscopic state space asymptotically grows
like a power law,

$\displaystyle||\bm{N}||=\sum_{N_{1}=0}^{N}\sum_{N_{2}=0}^{N_{1}}\cdots\sum_{N_{q-1}=0}^{N_{q-2}}1\,\overset{N\to\infty}{\sim}\frac{N^{q-1}}{(q-1)!},$
(24)

as opposed to the exponential growth of the microscopic state space.

Since it will be useful further below, we now make two important remarks.
First, a stationary mesoscopic distribution necessarely implies that all
microstates that belong to the respective mesostates are equiprobable. This
can be seen by first noting that in the stationary state, the microscopic
master equation (3) reduces to $0=\sum_{j}w_{ij}\,p_{j}$. Since the
microscopic transition rates (4) do not depend on the individual microstate
$\alpha_{{}_{\bm{N}}}$ belonging to a given mesostate $\bm{N}$, it follows
that the microscopic probability does not either in the stationary state so
that

$\displaystyle\mathbb{P}_{\alpha_{{}_{\bm{N}}}}^{s}=\frac{1}{\Omega_{\bm{N}}},\qquad
p^{s}_{\alpha_{{}_{\bm{N}}}}(\bm{\lambda})$
$\displaystyle=\frac{P^{s}_{\bm{N}}(\bm{\lambda})}{\Omega_{\bm{N}}}.$ (25)

A more formal proof is deferred to appendix A. Second, any microscopic initial
condition of the form
$p_{\alpha^{\prime}}^{sp}(0)=P_{\bm{N}^{\prime}}^{sp}(0)/\Omega_{\bm{N}}$ is
preserved at all times since the Hamiltonian (2) and thus the microscopic
transition rates (4) do not discriminate between the equienergetic microstates
inside the mesostate. Hence

$\displaystyle p_{\alpha_{{}_{\bm{N}}}}(t)$
$\displaystyle=\frac{P_{\bm{N}}(t)}{\Omega_{\bm{N}}}.$ (26)

An important implication is that if one only has experimental access to
physical observable that do not discriminate among the units, there is no way
to drive the system away from equipartition inside the mesostates. The system
can therfore be driven arbitrary far from its stationary state in terms of its
occupations but the equipartition within mesostates remains unaffected, i.e.
(26) holds.

We demonstrated that for thermodynamically consistent and discrete identical
systems with all-to-all interactions there is an exact coarse-graining of the
microscopic stochastic dynamics characterized by many-body states towards a
mesoscopic stochastic dynamics that is fully characterized by the global
occupation of the different unit states. It is however _a priori_ not obvious
that the thermodynamic structures built on top of these Markov process using
stochastic thermodynamics are equivalent. This issue is investigated in the
following section.

##  III Stochastic Thermodynamics

###  III.1 Trajectory Definitions

After having established the stochastic dynamics at microscopic and mesoscopic
scales, the following is devoted to formulating the stochastic thermodynamic
quantities across these scales. To this end, we first introduce the
fluctuating quantities at the level of a single trajectory. Generically, a
trajectory is denoted by $\bm{m}_{(\tau)}(t)$. This notation corresponds to
the specification of the actual state in the time interval under
consideration, $\bm{m}_{(\tau)}(t),\,t\leavevmode\nobreak\
\in\leavevmode\nobreak\ [t_{0},t_{f}]$. Here, $\tau$ is a parametrization of
the trajectory specifying the initial state
$\bm{m}_{(\tau)}(t_{0})=\alpha_{0}$, the subsequent jumps from $\alpha_{j-1}$
to $\alpha_{j}$ as well as the heat reservoir $\nu_{j}$ involved at the
instances of time, $t=\tau_{j},\;j=1,\ldots M$, and the final state,
$\bm{m}_{(\tau)}(t_{f})=\alpha_{M}$, where $M$ is the total number of jumps.
More explicitly, we write

$\displaystyle\bm{m}_{(\tau)}=\left\\{\bm{m}_{0}\overset{\nu_{1},\tau_{1}}{\longrightarrow}\bm{m}_{1}\overset{\nu_{2},\tau_{2}}{\longrightarrow}\bm{m}_{2}\overset{\nu_{3},\tau_{3}}{\longrightarrow}\ldots\overset{\nu_{j},\tau_{j}}{\longrightarrow}\bm{m}_{j}\overset{\nu_{j+1},\tau_{j+1}}{\longrightarrow}\ldots\bm{m}_{M-1}\overset{\nu_{M},\tau_{M}}{\longrightarrow}\bm{m}_{M}\right\\},$
(27)

and refer to Fig. 1 a) for an illustrative example of such a stochastic
trajectory.

Figure 1: Schematic representation of a single trajectory $\bm{m}_{(\tau)}$
during the time $[t_{0},t_{f}]$ in a) and the corresponding time-integrated
first law of thermodynamics for the same trajectory in b).

In the following, we will use lower scripts to label trajectory-dependent
quantities in microscopic representation and write $o[\bm{m}_{(\tau)},t]$ for
the value the observable $o$ takes at time $t$ for the trajectory
$\bm{m}_{(\tau)}$. We define the energy associated with the trajectory at time
$t$ to be given by the energy of the particular microstate $\alpha$ the system
is in for the trajectory under consideration, _i.e._

$\displaystyle
e[\bm{m}_{(\tau)},t]=\sum\limits_{\alpha}e_{\alpha}(\bm{\lambda}_{t})\,\delta_{\alpha,\bm{m}_{(\tau)}(t)},$
(28)

where the Kronecker delta $\delta_{\alpha,\bm{m}_{(\tau)}(t)}$ selects the
state $\alpha$ in which the trajectory is at the time under consideration. The
stochastic energy is a state function,

$\displaystyle\Delta
e[\bm{m}_{(\tau)},t]=\sum\limits_{\alpha}\big{[}e_{\alpha}(\bm{\lambda}_{t})\,\delta_{\alpha,\bm{m}_{(\tau)}(t)}-e_{\alpha}(\bm{\lambda}_{0})\,\delta_{\alpha,\bm{m}_{(\tau)}(0)}\big{]},$
(29)

as indicated by the notation $\Delta e$, and its time-derivative 111To
determine the time-derivative of the Kronecker delta, we realize that
$\dot{\delta}_{\alpha,\bm{m}_{(\tau)}(t)}$ goes from 0 to 1, and from 1 to 0,
when $\bm{m}_{(\tau)}(t)$ jumps into, or out of the microstate $\alpha$,
respectively, at time $t$. Hence the time-derivative consists of a sum of
delta functions, with weights 1 and -1, respectively, centered at the times,
$\tau_{j}$, of the jumps. can be decomposed as follows,

$\displaystyle\mathrm{d}_{t}\,e[\bm{m}_{(\tau)},t]$
$\displaystyle=\dot{q}[\bm{m}_{(\tau)},t]+\dot{w}[\bm{m}_{(\tau)},t],$ (30)

with the stochastic heat and work currents

$\displaystyle\dot{q}[\bm{m}_{(\tau)},t]$
$\displaystyle=\sum_{\nu=1}^{L}\sum\limits_{j=1}^{M}\delta(\nu-\nu_{j})\delta(t-\tau_{j})\left[e_{\alpha_{j}}(\bm{\lambda}_{\tau_{j}})-e_{\alpha_{j-1}}(\bm{\lambda}_{\tau_{j}})-\bm{f}^{(\nu_{j})}_{\alpha_{j},\alpha_{j-1}}\right]$
(31)
$\displaystyle=\sum_{\nu=1}^{L}\underbrace{-\sum\limits_{j=1}^{M}\delta(\nu-\nu_{j})\delta(t-\tau_{j})\,\frac{1}{\beta^{(\nu_{j})}}\,\ln\frac{w^{(\nu_{j})}_{\alpha_{j},\alpha_{j-1}}(\bm{\lambda}_{\tau_{j}})}{w^{(\nu_{j})}_{\alpha_{j-1},\alpha_{j}}(\bm{\lambda}_{\tau_{j}})}}_{\dot{q}^{(\nu)}[\bm{m}_{(\tau)},t]}$
$\displaystyle\dot{w}[\bm{m}_{(\tau)},t]$
$\displaystyle=\underbrace{\sum\limits_{\alpha}\big{[}\dot{\bm{\lambda}}_{t}\cdot\nabla_{\bm{\lambda}_{t}}\,e_{\alpha}(\bm{\lambda}_{t})\big{]}\,\delta_{\alpha,\bm{m}_{(\tau)}(t)}\Big{|}_{\bm{m}_{(\tau)}(t)}}_{\dot{w}_{\bm{\lambda}}[\bm{m}_{(\tau)},t]}+\sum_{\nu=1}^{L}\,\underbrace{\sum\limits_{j=1}^{M}\delta(\nu-\nu_{j})\delta(t-\tau_{j})\;\bm{f}^{(\nu_{j})}_{\alpha_{j},\alpha_{j-1}}}_{\dot{w}^{(\nu)}_{\bm{f}}[\bm{m}_{(\tau)},t]},$
(32)

where we introduced the notation
$\nabla_{\bm{\lambda}_{t}}=\big{(}\partial_{\lambda_{t}},\partial_{\lambda^{\prime}_{t}}\big{)}^{\top}$
and $\dot{x}|_{\bm{m}_{(\tau)}(t)}$ which corresponds to the instantaneous and
smooth changes of $x$ along the horizontal segments of the trajectory
$\bm{m}_{(\tau)(t)}$ in Fig. 1a). It will be proven instrumental to split the
fluctuating work current into the contribution
$\dot{w}_{\bm{\lambda}}[\bm{m}_{(\tau)},t]$ from the nonautonomous driving and
the dissipative contribution
$\sum_{\nu=1}^{L}\dot{w}^{(\nu)}_{\bm{f}}[\bm{m}_{(\tau)},t]$ due to the
nonconservative forces. It is noteworthy that Eq. (30) is the stochastic first
law and ensures energy conservation at the trajectory level Sekimoto (1998).
As an illustrative example, Fig. 1 b) shows the time-integrated stochastic
first law for the corresponding trajectory in a).

Next, the stochastic system entropy is defined as follows Seifert (2005);
Sheng  _et al._ (2019)

$\displaystyle s[\bm{m}_{(\tau)},t]=-\sum\limits_{\alpha}\ln
p_{\alpha}(t)\;\delta_{\alpha,\bm{m}_{(\tau)}(t)},$ (33)

and is therefore also a state-function,

$\displaystyle\Delta s[\bm{m}_{(\tau)},t]=-\sum\limits_{\alpha}\big{[}\ln
p_{\alpha}(t)\,\delta_{\alpha,\bm{m}_{(\tau)}(t)}-\ln
p_{\alpha}(0)\,\delta_{\alpha,\bm{m}_{(\tau)}(0)}\big{]},$ (34)

where we set $k_{B}\equiv 1$. Its time-derivative

$\displaystyle\mathrm{d}_{t}\,s[\bm{m}_{(\tau)},t]$
$\displaystyle=-\sum\limits_{\alpha}\frac{\partial_{t}p_{\alpha}(t)}{p_{\alpha}(t)}\delta_{\alpha,\bm{m}_{(\tau)}(t)}\Big{|}_{\bm{m}_{(\tau)}(t)}+\,\sum\limits_{j=1}^{M}\delta(t-\tau_{j})\ln\frac{p_{\alpha_{j-1}}(t)}{p_{\alpha_{j}}(t)}=\dot{s}_{e}[\bm{m}_{(\tau)},t]+\dot{\sigma}[\bm{m}_{(\tau)},t],$
(35)

can be split into the stochastic entropy flow

$\displaystyle\dot{s}_{e}[\bm{m}_{(\tau)},t]$
$\displaystyle=\sum_{\nu=1}^{L}-\sum\limits_{j=1}^{M}\delta(\nu-\nu_{j})\delta(t-\tau_{j})\,\ln\frac{w^{(\nu_{j})}_{\alpha_{j},\alpha_{j-1}}(\bm{\lambda}_{\tau_{j}})}{w^{(\nu_{j})}_{\alpha_{j-1},\alpha_{j}}(\bm{\lambda}_{\tau_{j}})}=\sum_{\nu=1}^{L}\beta^{(\nu)}\,\dot{q}^{(\nu)}[\bm{m}_{(\tau)},t],$
(36)

and the stochastic entropy production rate

$\displaystyle\dot{\sigma}[\bm{m}_{(\tau)},t]$
$\displaystyle=-\sum\limits_{\alpha}\frac{\partial_{t}p_{\alpha}(t)}{p_{\alpha}(t)}\delta_{\alpha,\bm{m}_{(\tau)}(t)}\Big{|}_{\bm{m}_{(\tau)}(t)}+\sum_{\nu=1}^{L}\sum\limits_{j=1}^{M}\delta(\nu-\nu_{j})\delta(t-\tau_{j})\,\ln\frac{w^{(\nu_{j})}_{\alpha_{j},\alpha_{j-1}}(\bm{\lambda}_{\tau_{j}})\,p_{\alpha_{j-1}}(t)}{w^{(\nu_{j})}_{\alpha_{j-1},\alpha_{j}}(\bm{\lambda}_{\tau_{j}})\,p_{\alpha_{j}}(t)}.$
(37)

We note that Eq. (35) corresponds to the entropy balance at the trajectory
level.

It will prove useful to also consider the time-integrated stochastic first law

$\displaystyle\Delta e[\bm{m}_{(\tau)},t]$
$\displaystyle\equiv\sum_{\nu=1}^{L}\delta e^{(\nu)}[\bm{m}_{(\tau)},t]=\delta
q[\bm{m}_{(\tau)},t]+\delta w[\bm{m}_{(\tau)},t],$ (38)

with the time-integrated fluctuating energy current

$\displaystyle\delta
e^{(\nu)}[\bm{m}_{(\tau)},t]=\int\limits_{0}^{t}\mathrm{d}t^{\prime}\sum\limits_{j=1}^{M}\delta(\nu-\nu_{j})\delta(t^{\prime}-\tau_{j})[e_{\alpha_{j}}-e_{\alpha_{j-1}}].$
(39)

and the fluctuating heat and work

$\displaystyle\delta q[\bm{m}_{(\tau)},t]$
$\displaystyle=\sum_{\nu=1}^{L}-\int\limits_{0}^{t}\mathrm{d}t^{\prime}\,\sum\limits_{j=1}^{M}\delta(\nu-\nu_{j})\delta(t^{\prime}-\tau_{j})\,\frac{1}{\beta^{(\nu_{j})}}\,\ln\frac{w^{(\nu_{j})}_{\alpha_{j},\alpha_{j-1}}(\bm{\lambda}_{\tau_{j}})}{w^{(\nu_{j})}_{\alpha_{j-1},\alpha_{j}}(\bm{\lambda}_{\tau_{j}})}=\sum_{\nu=1}^{L}\Big{(}\underbrace{\delta
e^{(\nu)}[\bm{m}_{(\tau)},t]-\delta
w_{\bm{f}}^{(\nu)}[\bm{m}_{(\tau)},t]}_{\delta
q_{\bm{f}}^{(\nu)}[\bm{m}_{(\tau)},t]}\Big{)}$ (40) $\displaystyle\delta
w[\bm{m}_{(\tau)},t]$
$\displaystyle=\underbrace{\int\limits_{0}^{t}\mathrm{d}t^{\prime}\sum\limits_{\alpha}\big{[}\dot{\bm{\lambda}}_{t^{\prime}}\cdot\nabla_{\bm{\lambda}_{t^{\prime}}}\,e_{\alpha}(\bm{\lambda}_{t^{\prime}})\big{]}\,\delta_{\alpha,\bm{m}_{(\tau)}(t^{\prime})}\Big{|}_{\bm{m}_{(\tau)}(t^{\prime})}}_{\delta
w_{\bm{\lambda}}[\bm{m}_{(\tau)},t]}+\;\sum_{\nu=1}^{L}\;\underbrace{\int\limits_{0}^{t}\mathrm{d}t^{\prime}\sum\limits_{j=1}^{M}\delta(\nu-\nu_{j})\delta(t^{\prime}-\tau_{j})\bm{f}^{(\nu)}_{\alpha_{j},\alpha_{j-1}}}_{\delta
w_{\bm{f}}^{(\nu)}[\bm{m}_{(\tau)},t]}.$ (41)

Using Eqs. (37) and (40), the entropy production can be written as follows

$\displaystyle\delta\sigma[\bm{m}_{(\tau)},t]=-\ln\frac{p_{\alpha_{{}_{M}}}(t)}{p_{\alpha_{{}_{0}}}(0)}+\sum_{\nu=1}^{L}\int\limits_{0}^{t}\mathrm{d}t^{\prime}\,\sum\limits_{j=1}^{M}\delta(\nu-\nu_{j})\delta(t^{\prime}-\tau_{j})\,\ln\frac{w^{(\nu_{j})}_{\alpha_{j},\alpha_{j-1}}(\bm{\lambda}_{\tau_{j}})}{w^{(\nu_{j})}_{\alpha_{j-1},\alpha_{j}}(\bm{\lambda}_{\tau_{j}})}=-\ln\frac{p_{\alpha_{{}_{M}}}(t)}{p_{\alpha_{{}_{0}}}(0)}-\sum_{\nu=1}^{L}\beta^{(\nu)}\delta
q^{(\nu)}[\bm{m}_{(\tau)},t].$ (42)

###  III.2 Generating Function Techniques

####  III.2.1 Microscopic Description

In the preceding section we introduced in detail all the relevant fluctuating
thermodynamic quantities. We now present techniques in order to compute the
statistics and features of these quantities as they will also prove useful to
determine if the thermodynamics is invariant under the dynamically exact
coarse-graining in Eq. (14). To this end, we consider the microscopic
generating function related to the change $\delta o[\bm{m}_{(\tau)},t]$ of the
fluctuating microscopic observable $o$ along a trajectory $\bm{m}_{(\tau)}$
conditioned to be in a microstate $\alpha$ at time $t$ which is defined as

$\displaystyle g_{\alpha}(\gamma_{o},t)$
$\displaystyle=p_{\alpha}(t)\langle\exp\\{-\gamma_{o}\,\delta
o[\bm{m}_{(\tau)},t]\\}\rangle_{\alpha},$ (43)

where $\langle\leavevmode\nobreak\ \cdot\leavevmode\nobreak\ \rangle_{\alpha}$
denotes an ensemble average over all trajectories that are in the microstate
$\alpha$ at time $t$ and $\gamma_{o}$ is the counting field (also bias). It
thus holds that $g(\gamma_{o},t)=\sum_{\alpha}g_{\alpha}(\gamma_{o},t)$. The
microscopic generating function can also be expressed as follows

$\displaystyle g(\mathrm{i}\gamma_{o},t)$
$\displaystyle=\int\limits_{-\infty}^{\infty}\mathrm{d}(\delta
o)\,\exp[-\mathrm{i}\,\gamma_{o}\,\delta o]\,p(\delta o,t),$ (44)

where $p(\delta o,t)$ is the probability to observe a change $\delta o$ in the
microscopic observable $o$ until time $t$. The different moments of the
microscopic observable $\delta o$ are obtained via the associated microscopic
generating function as follows,

$\displaystyle\langle\delta
o^{n}\rangle=(-1)^{n}\frac{\partial^{n}}{(\partial\gamma_{o})^{n}}\,g(\gamma_{o},t)\Big{|}_{\gamma_{o}=0}\;.$
(45)

The equation of motion for the microscopic generating function has the form of
a biased microscopic master equation Esposito  _et al._ (2007),

$\displaystyle\partial_{t}g_{\alpha}(\gamma_{o},t)=\sum\limits_{\alpha^{\prime}}w_{\alpha\alpha^{\prime}}(\gamma_{o},\bm{\lambda}_{t})\,g_{\alpha^{\prime}}(\gamma_{o},t),\quad
w_{\alpha\alpha^{\prime}}(\gamma_{o},\bm{\lambda}_{t})=-\gamma_{o}\,\partial_{t}o_{\alpha}\,\delta_{\alpha,\alpha^{\prime}}+\sum_{\nu=1}^{L}\exp\big{[}-\gamma_{o}\;o^{(\nu)}_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})\big{]}\,w^{(\nu)}_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t}),$
(46)

where $w_{\alpha\alpha^{\prime}}(\gamma_{o},\bm{\lambda}_{t})$ is the
microscopic biased generator. The notation $o_{\alpha}$ and
$o_{\alpha\alpha^{\prime}}$ refers to the value of the stochastic microscopic
observable in microstate $\alpha$ and its change during a transition from
state $\alpha^{\prime}$ to $\alpha$ while the system exchanges energy with the
reservoir $\nu$, respectively.

For state functions, $\delta o[\bm{m}_{(\tau)},t]=\Delta
o[\bm{m}_{(\tau)},t]=o[\bm{m}_{(\tau)},t]-o[\bm{m}_{(\tau)},0]$, the ensemble
average over all trajectories in Eq. (43) reduces to an ensemble average with
respect to the initial microstates of the trajectories only. Consequently, the
microscopic generating function associated with any state function has the
simple closed form

$\displaystyle g(\gamma_{o},t)$
$\displaystyle=\sum\limits_{\alpha,\alpha^{\prime}}\exp\big{\\{}-\gamma_{o}\,[o_{\alpha}(t)-o_{\alpha^{\prime}}(0)]\big{\\}}\,p_{\alpha}(t)\,p_{\alpha^{\prime}}(0).$
(47)

Using Eqs. (28) and (33), we have for the microscopic generating functions
associated with the stochastic state-like observables energy and entropy,

$\displaystyle g(\gamma_{e},t)$
$\displaystyle=\sum\limits_{\alpha,\alpha^{\prime}}\exp\big{\\{}-\gamma_{e}\,[e_{\alpha}(\bm{\lambda}_{t})-e_{\alpha^{\prime}}(\bm{\lambda}_{0})]\big{\\}}\,p_{\alpha}(t)\,p_{\alpha^{\prime}}(0)$
(48) $\displaystyle g(\gamma_{s},t)$
$\displaystyle=\sum\limits_{\alpha,\alpha^{\prime}}\exp\big{\\{}\gamma_{s}\big{[}\ln
p_{\alpha}(t)-\ln
p_{\alpha^{\prime}}(0)\big{]}\big{\\}}\,p_{\alpha}(t)\,p_{\alpha^{\prime}}(0).$
(49)

Moreover, substituting Eqs. (31), (32), (36) and (37) into Eq. (46), we obtain
for the microscopic generating functions associated with the currents

$\displaystyle\partial_{t}g_{\alpha}(\gamma_{q},t)$
$\displaystyle=\sum_{\nu=1}^{L}\sum\limits_{\alpha^{\prime}}\exp\big{\\{}-\gamma_{q}\big{[}e_{\alpha}(\bm{\lambda}_{t})-e_{\alpha^{\prime}}(\bm{\lambda}_{t})-\bm{f}^{(\nu)}_{\alpha\alpha^{\prime}}\big{]}\big{\\}}\;w^{(\nu)}_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})\;g_{\alpha^{\prime}}(\gamma_{q},t)$
(50) $\displaystyle\partial_{t}g_{\alpha}(\gamma_{w},t)$
$\displaystyle=-\gamma_{w}\,\dot{\bm{\lambda}}_{t}\cdot\left[\nabla_{\bm{\lambda}_{t}}\,e_{\alpha}(\bm{\lambda}_{t})\right]\,g_{\alpha}(\gamma_{w},t)+\sum_{\nu=1}^{L}\sum\limits_{\alpha^{\prime}}\exp\big{[}-\gamma_{w}\,\bm{f}^{(\nu)}_{\alpha\alpha^{\prime}}\big{]}\;w^{(\nu)}_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})\;g_{\alpha^{\prime}}(\gamma_{w},t)$
(51) $\displaystyle\partial_{t}g_{\alpha}(\gamma_{s_{e}},t)$
$\displaystyle=\sum_{\nu=1}^{L}\sum\limits_{\alpha^{\prime}}\exp\big{\\{}\gamma_{s_{e}}\big{[}\ln
w^{(\nu)}_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})-\ln
w^{(\nu)}_{\alpha^{\prime}\alpha}(\bm{\lambda}_{t})\big{]}\big{\\}}\;w^{(\nu)}_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})\;g_{\alpha^{\prime}}(\gamma_{s_{e}},t)$
(52) $\displaystyle\partial_{t}g_{\alpha}(\gamma_{\sigma},t)$
$\displaystyle=\gamma_{\sigma}\,\frac{\partial_{t}p_{\alpha}(t)}{p_{\alpha}(t)}\,g_{\alpha}(\gamma_{\sigma},t)+\sum_{\nu=1}^{L}\sum\limits_{\alpha^{\prime}}\exp\big{\\{}-\gamma_{\sigma}\big{[}\ln
w^{(\nu)}_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})\,p_{\alpha^{\prime}}(t)-\ln
w^{(\nu)}_{\alpha^{\prime}\alpha}(\bm{\lambda}_{t})p_{\alpha}(t)\big{]}\big{\\}}\;w^{(\nu)}_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})\;g_{\alpha^{\prime}}(\gamma_{\sigma},t).$
(53)

####  III.2.2 Mesoscopic Description

We rewrite the microscopic generating function (43) as follows

$\displaystyle
g_{\alpha_{{}_{\bm{N}}}}(\gamma_{o},t)=P_{\bm{N}}(t)\;\mathbb{P}_{\alpha_{{}_{\bm{N}}}}(t)\,\langle\exp\big{\\{}-\gamma_{o}\,\delta
o[\bm{m}_{(\tau)},t]\big{\\}}\rangle_{\alpha_{{}_{\bm{N}}}},$ (54)

and define the mesososcopic generating function

$\displaystyle
G_{\bm{N}}(\gamma_{{}_{O}},t)\equiv\sum\limits_{\alpha_{\bm{N}}}g_{\alpha_{{}_{\bm{N}}}}(\gamma_{{}_{o}},t)=P_{\bm{N}}(t)\,\sum\limits_{\alpha_{\bm{N}}}\mathbb{P}_{\alpha_{{}_{\bm{N}}}}(t)\,\langle\exp\big{\\{}-\gamma_{{}_{o}}\,\delta
o[\bm{m}_{(\tau)},t]\big{\\}}\rangle_{\alpha_{{}_{\bm{N}}}},$ (55)

where $\langle\leavevmode\nobreak\ \cdot\leavevmode\nobreak\
\rangle_{\alpha_{{}_{\bm{N}}}}$ and $\langle\leavevmode\nobreak\
\cdot\leavevmode\nobreak\ \rangle_{\bm{N}}$ denote ensemble averages over all
trajectories that are in the microstate $\alpha$ belonging to a given
mesostate $\bm{N}$ and over all those that are in mesostate $\bm{N}$ at time
$t$, respectively. Moreover, $O$ denotes a mesoscopic observable defined along
a trajectory propagating in the mesoscopic state space, $\bm{M}_{(\tau)}$,
which we write as $O[\bm{M}_{(\tau)},t]$ in the following. Since the
trajectory observables $o=e,q,w,s_{e}$ do not depend on microscopic
information [cf. Eqs. (28)–(32)], we have for those observables that
$o[\bm{m}_{(\tau)},t]=O[\bm{M}_{(\tau)},t]$ and Eq. (55) closes as follows

$\displaystyle
G_{\bm{N}}(\gamma_{{}_{O}},t)=P_{\bm{N}}(t)\,\sum\limits_{\alpha_{\bm{N}}}\mathbb{P}_{\alpha_{{}_{\bm{N}}}}(t)\,\langle\exp\big{\\{}-\gamma_{{}_{O}}\,\delta
O[\bm{M}_{(\tau)},t]\big{\\}}\rangle_{\bm{N}}=P_{\bm{N}}(t)\,\langle\exp\big{\\{}-\gamma_{{}_{O}}\,\delta
O[\bm{M}_{(\tau)},t]\big{\\}}\rangle_{\bm{N}},\quad O=E,Q,W,S_{e}.$ (56)

Thus, the microscopic generating function for the energy (48) in mesoscopic
representation reads

$\displaystyle G(\gamma_{{}_{E}},t)$
$\displaystyle=\sum\limits_{\bm{N},\bm{N}^{\prime}}\exp\big{\\{}-\gamma_{{}_{E}}\,[E_{{}_{\bm{N}}}(\bm{\lambda}_{t})-E_{{}_{\bm{N}^{\prime}}}(\bm{\lambda}_{0})]\big{\\}}\,P_{\bm{N}}(t)\,P_{\bm{N}^{\prime}}(0)=g(\gamma_{e},t),$
(57)

and from the microscopic equation of motion for the generating function (46)
we get

$\displaystyle\partial_{t}G_{\bm{N}}(\gamma_{{}_{O}},t)$
$\displaystyle=\sum\limits_{\bm{N}^{\prime}}W_{\bm{N}\bm{N}^{\prime}}(\gamma_{{}_{O}},\bm{\lambda}_{t})\;G_{\bm{N}^{\prime}}(\gamma_{{}_{O}},t),$
(58)

with the mesoscopic biased generator

$\displaystyle W_{\bm{N}\bm{N}^{\prime}}(\gamma_{{}_{O}},\bm{\lambda}_{t})$
$\displaystyle=-\gamma_{{}_{O}}\dot{O}_{\bm{N}}(\bm{\lambda}_{t})\,\delta_{\bm{N},\bm{N}^{\prime}}+\sum_{\nu=1}^{L}\exp\big{[}-\gamma_{{}_{O}}\,O^{(\nu)}_{\bm{N},\bm{N}^{\prime}}(\bm{\lambda}_{t})\big{]}\;W^{(\nu)}_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda}_{t}),$
(59)

for $O=E,Q,W,S_{e}$. More explicitly, Eqs. (50), (51) and (52) can be
rewritten in mesoscopic representation as follows

$\displaystyle\partial_{t}G_{\bm{N}}(\gamma_{{}_{Q}},t)$
$\displaystyle=\sum_{\nu=1}^{L}\sum\limits_{\bm{N}^{\prime}}\exp\big{\\{}-\gamma_{{}_{Q}}\,\big{[}E_{\bm{N}}(\bm{\lambda}_{t})-E_{\bm{N}^{\prime}}(\bm{\lambda}_{t})-\bm{f}^{(\nu)}_{\bm{N}\bm{N}^{\prime}}\big{]}\big{\\}}\;W^{(\nu)}_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda}_{t})\;G_{\bm{N}^{\prime}}(\gamma_{{}_{Q}},t)$
(60) $\displaystyle\partial_{t}G_{\bm{N}}(\gamma_{{}_{W}},t)$
$\displaystyle=-\gamma_{{}_{W}}\,\dot{\bm{\lambda}}_{t}\cdot\left[\nabla_{\bm{\lambda}_{t}}\,E_{\bm{N}}(\bm{\lambda}_{t})\right]G_{\bm{N}}(\gamma_{{}_{W}},t)+\sum_{\nu=1}^{L}\sum\limits_{\bm{N}^{\prime}}\exp\big{[}-\gamma_{{}_{W}}\,\bm{f}^{(\nu)}_{\bm{N}\bm{N}^{\prime}}\big{]}\;W^{(\nu)}_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda}_{t})\;G_{\bm{N}^{\prime}}(\gamma_{{}_{W}},t)$
(61) $\displaystyle\partial_{t}G_{\bm{N}}(\gamma_{{}_{S_{e}}},t)$
$\displaystyle=\sum_{\nu=1}^{L}\sum\limits_{\bm{N}^{\prime}}\exp\Big{\\{}\gamma_{{}_{S_{e}}}\Big{[}\ln
W^{(\nu)}_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda}_{t})-\ln
W^{(\nu)}_{\bm{N}^{\prime}\bm{N}}(\bm{\lambda}_{t})-\big{(}S^{int}_{\bm{N}}-S^{int}_{\bm{N}^{\prime}}\big{)}\Big{]}\Big{\\}}\;W^{(\nu)}_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda}_{t})\;G_{\bm{N}^{\prime}}(\gamma_{{}_{S_{e}}},t).$
(62)

It is easy to verify that
$\sum_{\bm{N}}\partial_{t}G_{\bm{N}}(\gamma_{{}_{O}},t)=\sum_{\alpha}\partial_{t}g_{\alpha}(\gamma_{o},t)$
for $O=E,Q,W,S_{e}$ and $o=e,q,w,s_{e}$. Thus, we find that the statistics of
the stochastic first law in microscopic representation (30) is invariant under
coarse-graining.

Conversely, the stochastic system entropy (33) and stochastic entropy
production rate (37) are functions of the microscopic ensemble probability.
The corresponding equation for the mesoscopic generating function (55) would,
in general, not be closed and the stochastic entropy balance in microscopic
representation (35) is, in general, not invariant under the coarse-graining.
However, an exact coarse-graining is possible whenever the microscopic
probabilities are uniform within each mesostate, i.e. (26) holds. In this case
the mesoscopic generating functions associated with the system entropy and
entropy production rate read, respectively

$\displaystyle G(\gamma_{{}_{S}},t)$
$\displaystyle=\sum\limits_{\bm{N},\bm{N}^{\prime}}\exp\big{\\{}\gamma_{{}_{S}}\big{[}\ln
P_{\bm{N}}(t)-\ln
P^{sp}_{\bm{N}^{\prime}}(0)-\big{(}S^{int}_{\bm{N}}-S^{int}_{\bm{N}^{\prime}}\big{)}\big{]}\big{\\}}\,P_{\bm{N}}(t)P_{\bm{N}^{\prime}}^{sp}(0)=g(\gamma_{s},t)$
(63) $\displaystyle\partial_{t}G_{\bm{N}}(\gamma_{{}_{\Sigma}},t)$
$\displaystyle=\gamma_{{}_{\Sigma}}\frac{\partial_{t}P_{\bm{N}}(t)}{P_{\bm{N}}(t)}\,G_{\bm{N}}(\gamma_{{}_{\Sigma}},t)+\sum_{\nu=1}^{L}\sum\limits_{\bm{N}^{\prime}}\exp\Big{\\{}-\gamma_{{}_{\Sigma}}\ln\frac{W^{(\nu)}_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda}_{t})\,P_{\bm{N}^{\prime}}(t)}{W^{(\nu)}_{\bm{N}^{\prime}\bm{N}}(\bm{\lambda}_{t})\,P_{\bm{N}}(t)}\Big{\\}}\,W^{(\nu)}_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda}_{t})\;G_{\bm{N}^{\prime}}(\gamma_{{}_{\Sigma}},t),$
(64)

with
$\sum_{\bm{N}}\partial_{t}G_{\bm{N}}(\gamma_{{}_{\Sigma}},t)=\sum_{\alpha}\partial_{t}g_{\alpha}(\gamma_{\sigma},t)$.
Hence we conclude that the statistics of the stochastic entropy balance (35)
is invariant under the coarse-graining, if one considers initial conditions
which are uniform within each mesostate, or for systems in stationary states.

Comparing Eqs. (48), (50) and (51) with Eqs. (57), (60) and (61), we note that
the evolution of the generating functions associated with the first-law
observables, that is energy, heat and work, have the same form in microscopic
and mesoscopic representation. In contrast, the mesoscopic generating
functions associated with the entropies do not have the same form as the
microscopic ones but also contain the internal entropy $S^{int}$. This is due
to the coarse-grained degrees of freedom that give rise to Boltzmann entropies
(19) assigned to the mesostates. Physically, the conditions for the invariance
of the stochastic entropy balance [Eqs. (63) and (64)] can be understood as
follows. If the microscopic degrees of freedom inside the mesostates are not
equiprobable, there are transient microscopic currents that can not be
captured at the mesoscopic level and which only vanish identically once the
uniform probability distributions inside the mesostates are achieved.

So far, we have established two descriptions of the stochastic thermodynamics
at the microscopic and mesoscopic level. These two formulations are equivalent
for the stochastic first law. In case of the stochastic entropy balance, the
microscopic and mesoscopic thermodynamics coincide under the condition that
the microstates inside each mesostate are equiprobable. The thermodynamics
consistency at each level is ensured by the respective local detailed balance
conditions in Eqs. (5) and (17). Alternatively, the thermodynamic consistency
is also encoded by the so-called detailed fluctuation theorem for the
stochastic entropy production. In the following, we will discuss this symmetry
of the fluctuations of the entropy production as it will be of importance
further below.

###  III.3 Detailed Fluctuation Theorems Across Scales

Let us consider a forward process that starts from a state that is at
equilibrium with respect to the reference reservoir $\nu=1$,

$\displaystyle
p_{\alpha_{{}_{0}}}^{eq}(\bm{\lambda}_{0})=\exp\big{\\{}-\beta^{(1)}[e_{\alpha_{{}_{0}}}(\bm{\lambda}_{0})-a^{eq}(\bm{\lambda}_{0})]\big{\\}}\,.$
(65)

The system then evolves under the driven microscopic Markov process according
to the forward protocol
$\bm{\lambda}_{t^{\prime}},\,t^{\prime}\leavevmode\nobreak\
\in\leavevmode\nobreak\ [0,t]$. For the backward process, indicated by the
notation “$\tilde{\phantom{w}}$”, the system is initially prepared in the
final equilibrium state of the forward process

$\displaystyle
p_{\alpha_{{}_{M}}}^{eq}(\bm{\lambda}_{t})=\exp\big{\\{}-\beta^{(1)}[e_{\alpha_{{}_{M}}}(\bm{\lambda}_{t})-a^{eq}(\bm{\lambda}_{t})]\big{\\}}\,,$
(66)

and subsequently evolves under the time-reversed driven microscopic Markov
process according to the backward protocol
$\tilde{\bm{\lambda}}_{t^{\prime}}=\bm{\lambda}_{t-t^{\prime}},\,t^{\prime}\leavevmode\nobreak\
\in\leavevmode\nobreak\ [0,t]$. Then, the following microscopic finite-time
detailed fluctuation theorem ensues Bulnes Cuetara  _et al._ (2014); Rao and
Esposito (2018b)

$\displaystyle\ln\frac{p\Big{(}\beta^{(1)}\delta
w_{\bm{\lambda}}+\sum\limits_{\nu=1}^{L}\big{[}\beta^{(\nu)}\delta
w_{\bm{f}}^{(\nu)}+\big{[}\beta^{(1)}-\beta^{(\nu)}\big{]}\delta
e^{(\nu)}\big{]}\Big{)}}{\tilde{p}\Big{(}-\beta^{(1)}\delta
w_{\bm{\lambda}}-\sum\limits_{\nu=1}^{L}\big{[}\beta^{(\nu)}\delta
w_{\bm{f}}^{(\nu)}+\big{[}\beta^{(1)}-\beta^{(\nu)}\big{]}\delta
e^{(\nu)}\big{]}\Big{)}}=\beta^{(1)}\big{[}\delta w_{\bm{\lambda}}-\Delta
a^{eq}_{1}\big{]}+\sum\limits_{\nu=1}^{L}\big{[}\beta^{(\nu)}\delta
w_{\bm{f}}^{(\nu)}+\big{[}\beta^{(1)}-\beta^{(\nu)}\big{]}\delta
e^{(\nu)}\big{]},$ (67)

where $\Delta
a^{eq}_{1}=a^{eq}_{1}(\bm{\lambda}_{t})-a^{eq}_{1}(\bm{\lambda}_{0})$ denotes
the change in global microscopic equilibrium free energy with respect to the
reservoir $\nu=1$ along the forward process that only depends on the initial
and final value of the driving protocol and thus does not fluctuate.

In fact, this microscopic finite-time detailed fluctuation theorem also holds
for the joint probability distribution,

$\displaystyle\ln\frac{p\Big{(}\beta^{(1)}\delta
w_{\bm{\lambda}}\,,\,\\{\delta j^{(\nu)}_{\bm{f}}\\}\,,\,\\{\delta
j^{(\nu)}_{e}\\}\Big{)}}{\tilde{p}\Big{(}-\beta^{(1)}\delta
w_{\bm{\lambda}}\,,\,\\{-\delta j^{(\nu)}_{\bm{f}}\\}\,,\,\\{-\delta
j^{(\nu)}_{e}\\}\Big{)}}=\beta^{(1)}\big{[}\delta w_{\bm{\lambda}}-\Delta
a^{eq}_{1}\big{]}+\sum\limits_{\nu=1}^{L}\big{[}\beta^{(\nu)}\delta
w_{\bm{f}}^{(\nu)}+\big{[}\beta^{(1)}-\beta^{(\nu)}\big{]}\delta
e^{(\nu)}\big{]},$ (68)

where we write the time-integrated microscopic autonomous work currents as
$\\{\delta j^{(\nu)}_{\bm{f}}\\}\equiv\big{(}\,\beta^{(1)}\delta
w_{\bm{f}}^{(1)},\ldots,\beta^{(L)}\delta w_{\bm{f}}^{(L)})$ and the time-
integrated microscopic energy currents as $\\{\delta
j^{(\nu)}_{e}\\}\equiv([\beta^{(1)}-\beta^{(2)}]\delta
e^{(2)},\ldots,[\beta^{(1)}-\beta^{(L)}]\delta e^{(L)}\,\big{)}$. Here,
$p(\beta^{(1)}\delta w_{\bm{\lambda}},\\{\delta
j^{(\nu)}_{\bm{f}}\\},\\{\delta j^{(\nu)}_{e}\\})$ is the probability to
observe a microscopic nonautonomous work $\beta^{(1)}\delta w_{\bm{\lambda}}$,
the microscopic time-integrated autonomous work currents $\\{\delta
j^{(\nu)}_{\bm{f}}\\}$ and the microscopic time-integrated energy currents
$\\{\delta j^{(\nu)}_{e}\\}$ along the forward process in the microscopic
state space. Conversely, $\tilde{p}(-\beta^{(1)}\delta
w_{\bm{\lambda}},\\{-\delta j^{(\nu)}_{\bm{f}}\\},\\{-\delta
j^{(\nu)}_{e}\\})$ is the probability to observe a microscopic nonautonomous
work $-\beta^{(1)}\delta w_{\bm{\lambda}}$, the microscopic time-integrated
autonomous work currents $\\{-\delta j^{(\nu)}_{\bm{f}}\\}$ and the
microscopic time-integrated energy currents $\\{-\delta j^{(\nu)}_{e}\\}$
along the time-reversed backward process in the microscopic state space.

The validity of the last equation can be seen by marginalizing its l.h.s.
which gives the l.h.s. of Eq. (67). Equation (68) can also be derived via the
following symmetry of the associated microscopic generating function

$\displaystyle
g\big{(}\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},t\big{)}=\tilde{g}\big{(}1-\gamma_{{}_{\bm{\lambda}}},\\{1-\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{1-\gamma_{{}_{e}}^{(\nu)}\\},t\big{)}\;\exp\big{[}-\beta^{(1)}\Delta
a^{eq}_{1}(\bm{\lambda})\big{]},$ (69)

as demonstrated in appendix B.

Analogously, we can define the forward and backward process as above also in
the mesoscopic state space. In this case, the equilibrum distributions for the
forward and, in reversed order for the backward trajectory, read, respectively

$\displaystyle P_{\bm{N}_{{}_{0}}}^{eq}(\bm{\lambda}_{0})$
$\displaystyle=\exp\big{\\{}-\beta^{(1)}[A_{\bm{N}_{{}_{0}}}(\bm{\lambda}_{0})-A^{eq}(\bm{\lambda}_{0})]\big{\\}}$
(70) $\displaystyle P_{\bm{N}_{{}_{M}}}^{eq}(\bm{\lambda}_{t})$
$\displaystyle=\exp\big{\\{}-\beta^{(1)}[A_{\bm{N}_{{}_{M}}}(\bm{\lambda}_{t})-A^{eq}(\bm{\lambda}_{t})]\\}\,.$
(71)

Crucially, all fluctuating quantities appearing in the microscopic detailed
fluctuation theorem (68) are invariant under the dynamically exact coarse-
graining (14). Consequently, the symmetry for the microscopic generating
function (69) is also exhibited at the mesoscopic level,

$\displaystyle
G(\bm{\gamma},t)=\tilde{G}(\tilde{\bm{\gamma}},t)\;\exp\big{[}-\beta^{(1)}\Delta
A^{eq}_{1}(\bm{\lambda})\big{]},$ (72)

where $\Delta
A^{eq}_{1}=A^{eq}_{1}(\bm{\lambda}_{t})-A^{eq}_{1}(\bm{\lambda}_{0})$.
Moreover, for brevity we introduced the notation

$\displaystyle\bm{\gamma}\equiv\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{E}^{(\nu)}\\},\quad\tilde{\bm{\gamma}}\equiv
1-\gamma_{{}_{\bm{\lambda}}},\\{1-\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{1-\gamma_{E}^{(\nu)}\\},$
(73)

and the mesoscopic time-integrated autonomous work currents $\\{\delta
J^{(\nu)}_{\bm{f}}\\}\equiv\big{(}\,\beta^{(1)}\delta
W_{\bm{f}}^{(1)},\ldots,\beta^{(L)}\delta W_{\bm{f}}^{(L)})$ as well as the
mesoscopic time-integrated energy currents $\\{\delta
J^{(\nu)}_{E}\\}\leavevmode\nobreak\ \equiv\leavevmode\nobreak\
([\beta^{(1)}-\beta^{(2)}]\delta
E^{(2)},\ldots,[\beta^{(1)}-\beta^{(L)}]\delta E^{(L)}\,\big{)}$. Thus, the
detailed fluctuation theorem (68) also holds at the mesoscopic level,

$\displaystyle\ln\frac{P\Big{(}\beta^{(1)}\delta
W_{\bm{\lambda}}\,,\,\\{\delta J^{(\nu)}_{\bm{f}}\\}\,,\,\\{\delta
J^{(\nu)}_{E}\\}\Big{)}}{\tilde{P}\Big{(}-\beta^{(1)}\delta
W_{\bm{\lambda}}\,,\,-\\{\delta J^{(\nu)}_{\bm{f}}\\}\,,\,-\\{\delta
J^{(\nu)}_{E}\\}\Big{)}}=\beta^{(1)}\big{[}\delta W_{\bm{\lambda}}-\Delta
A^{eq}_{1}\big{]}+\sum\limits_{\nu=1}^{L}\big{[}\beta^{(\nu)}\delta
W_{\bm{f}}^{(\nu)}+\big{[}\beta^{(1)}-\beta^{(\nu)}\big{]}\delta
E^{(\nu)}\big{]},$ (74)

where $P\Big{(}\beta^{(1)}\delta W_{\bm{\lambda}}\,,\,\\{\delta
J^{(\nu)}_{{}_{\bm{f}}}\\}\,,\,\\{\delta J^{(\nu)}_{E}\\}\Big{)}$ is the
probability to observe a mesoscopic nonautonomous work $\beta^{(1)}\delta
W_{\bm{\lambda}}$, the mesoscopic time-integrated autonomous work currents
$\\{\delta J^{(\nu)}_{\bm{f}}\\}$ and the mesoscopic time-integrated energy
currents $\\{\delta J^{(\nu)}_{E}\\}$ along the forward process in the
mesoscopic state space. Conversely, $\tilde{P}\Big{(}-\beta^{(1)}\delta
W_{\bm{\lambda}}\,,\,\\{-\delta J^{(\nu)}_{\bm{f}}\\}\,,\,\\{-\delta
J^{(\nu)}_{E}\\}\Big{)}$ is the probability to observe a mesoscopic
nonautonomous work $-\beta^{(1)}\delta W_{\bm{\lambda}}$, the mesoscopic time-
integrated autonomous work currents $\\{-\delta J^{(\nu)}_{{}_{\bm{f}}}\\}$
and the mesoscopic time-integrated energy currents $\\{-\delta
J^{(\nu)}_{E}\\}$ along the time-reversed backward process in the mesoscopic
state space.

Having stated the various detailed fluctuation theorems across scales, we now
proceed to show that the latter are relations for the entropy production of
the forward processes including the relaxation from the nonequilibrium state
at time $t$ towards the final equilibrium state of the forward process (66)
which coincides with the initial equilibrium state of the backward process.
First, we note that initial state (65) can be prepared by disconnecting all
other heat reservoirs, fixing the protocol at value $\bm{\lambda}_{0}$ and
letting the system relax. At time $t^{\prime}=0$, all other heat reservoirs
are simultaneously connected to the system and both the nonconservative
$\bm{f}^{(\nu)}$ and the nonautonomous driving is switched on. As a result,
the system evolves under the driven microscopic Markov process according to
the forward protocol
$\bm{\lambda}_{t^{\prime}},\,t^{\prime}\leavevmode\nobreak\
\in\leavevmode\nobreak\ [0,t]$ towards a nonequilibrium state
$p_{\alpha}^{neq}(t)$. During that evolution heat $\delta
q_{\bm{\lambda}}^{(\nu)}[\bm{m}_{(\tau)},t]$ is exchanged between the system
and the reservoirs $\nu$. There is furthermore autonomous $\delta
w_{\bm{f}}^{(\nu)}[\bm{m}_{(\tau)},t]$ work done on or by the system as well
as nonautonomous work $\delta w_{\bm{\lambda}}[\bm{m}_{(\tau)},t]$ performed
on the system by the external driving to change its energy landscape
$e_{\alpha}(\bm{\lambda}_{t}^{\prime})$. At time $t$, all heat reservoirs but
the reference one $\nu=1$ are disconnected, the driving parameter is kept
constant at its final value $\bm{\lambda}_{t}$ and the nonconservative force
$\bm{f}$ is switched off such that the system relaxes into the equilibrium
state (66). The preparation of the starting and ending distribution of the
backward process is analogous. The forward and backward process are
illustrated in Fig. 2.

Figure 2: Schematic representation of the backward and forward process.

Using Eqs. (38)–(41), (65) and (66), the fluctuating entropy production (42)
along the forward process can be rewritten as follows

$\displaystyle\delta\sigma[\bm{m}_{(\tau)},t]=\beta^{(1)}\big{[}\delta
w_{\bm{\lambda}}[\bm{m}_{(\tau)},t]-\Delta
a^{eq}_{1}\big{]}+\sum_{\nu=1}^{L}\big{\\{}\beta^{(\nu)}\delta
w_{\bm{f}}^{(\nu)}[\bm{m}_{(\tau)},t]+\big{[}\beta^{(1)}-\beta^{(\nu)}\big{]}\delta
e^{(\nu)}[\bm{m}_{(\tau)},t]\big{\\}},$ (75)

which is exactly the r.h.s of the detailed fluctuation theorem (67). Thus, the
detailed fluctuation theorem (67) is a symmetry relation for the entropy
production not only from initial time $0$ to the time of the final protocol
value $t$ but including also the relaxation contribution from time $t$ until
the final equilibrium distribution is attained. Though, it is a _finite-time_
relation since all fluctuating quantities in the entropy production of the
forward process (75) stop evolving at time $t$ and do thus not contribute of
the statistics of the following relaxation process.

We want to stress that the existence of the detailed fluctuation theorem for
the entropy production across scales (68), (74) ensures that the
thermodynamics formulated at each of these levels is consistent. We will make
use of this result further below when we formulate the fluctuations at the
macroscopic level, that is fluctuations that scale exponentially with the
system size $N$.

###  III.4 Microscopic And Mesoscopic First And Second Law

Before turning to the macroscopic limit, for completeness, we want to
formulate the thermodynamics at the ensemble level on microscopic and
mesoscopic scales and hereby, because of their importance, focus on the laws
of thermodynamics. Using Eq. (45) and Eqs. (48) – (51) or Eqs. (57) – (61), we
arrive at the microscopic or mesoscopic first law of thermodynamics,
respectively,

$\displaystyle\mathrm{d}_{t}e(t)=\dot{q}(t)+\dot{w}(t),\quad\mathrm{d}_{t}E(t)=\dot{Q}(t)+\dot{W}(t),$
(76)

with the average internal energy that is equivalent at microscopic and
mesoscopic scale,

$\displaystyle
e(t)=\sum\limits_{\alpha}e_{\alpha}(\bm{\lambda}_{t})\;p_{\alpha}(t)=\sum\limits_{\bm{N}}E_{\bm{N}}(\bm{\lambda}_{t})\;P_{\bm{N}}(t)=E(t).$
(77)

and with the equivalent microscopic and mesoscopic heat currents

$\displaystyle\dot{q}(t)$
$\displaystyle=\sum\limits_{\nu=1}^{L}\sum\limits_{\alpha,\alpha^{\prime}}\left[e_{\alpha}(\bm{\lambda}_{t})-e_{\alpha^{\prime}}(\bm{\lambda}_{t})-\bm{f}^{(\nu)}_{\alpha\alpha^{\prime}}\right]\;w_{\alpha\alpha^{\prime}}^{(\nu)}(\bm{\lambda}_{t})\;p_{\alpha^{\prime}}(t)$
(78)
$\displaystyle=\sum\limits_{\nu=1}^{L}\sum\limits_{\bm{N},\bm{N}^{\prime}}\left[E_{\bm{N}}(\bm{\lambda}_{t})-E_{\bm{N}^{\prime}}(\bm{\lambda}_{t})-\bm{f}^{(\nu)}_{\bm{N}\bm{N}^{\prime}}\right]\;W_{\bm{N}\bm{N}^{\prime}}^{(\nu)}(\bm{\lambda}_{t})\;P_{\bm{N}^{\prime}}(t)=\dot{Q}(t)$

as well as the equivalent microscopic and mesoscopic work currents

$\displaystyle\dot{w}(t)$
$\displaystyle=\sum_{\alpha}\Big{[}\dot{\bm{\lambda}}_{t}\cdot\left[\nabla_{\bm{\lambda}_{t}}\,E_{\alpha}(\bm{\lambda}_{t})\right]\,p_{\alpha}(t)+\sum\limits_{\nu=1}^{L}\sum\limits_{\alpha^{\prime}}\bm{f}^{(\nu)}_{\alpha\alpha^{\prime}}\;w_{\alpha,\alpha^{\prime}}^{(\nu)}(\bm{\lambda}_{t})\;p_{\alpha^{\prime}}(t)\Big{]}$
(79)
$\displaystyle=\sum_{\bm{N}}\\!\Big{[}\dot{\bm{\lambda}}_{t}\cdot\left[\nabla_{\bm{\lambda}_{t}}\,E_{\bm{N}}(\bm{\lambda}_{t})\right]P_{\bm{N}}(t)+\sum\limits_{\nu=1}^{L}\sum\limits_{\bm{N}^{\prime}}\bm{f}^{(\nu)}_{\bm{N}\bm{N}^{\prime}}\,W_{\bm{N}\bm{N}^{\prime}}^{(\nu)}(\bm{\lambda}_{t})\,P_{\bm{N}^{\prime}}(t)\Big{]}=\dot{W}(t).$

Next, with Eq. (63), which only holds for equiprobable microstates inside the
mesostates (26), we find the equivalence of the average system entropy at
microscopic and mesoscopic scale,

$\displaystyle s(t)=-\sum\limits_{\alpha}p_{\alpha}(t)\,\ln
p_{\alpha}(t)=\sum\limits_{\bm{N}}\left[S^{int}_{\bm{N}}-\ln
P_{\bm{N}}(t)\right]\,P_{\bm{N}}(t)=S(t).$ (80)

Using furthermore Eq. (64), which only holds for equiprobable microstates
inside the mesostates (26), the microscopic and mesoscopic second law of
thermodynamics reads

$\displaystyle\dot{\sigma}(t)=\sum\limits_{\nu=1}^{L}\sum\limits_{\alpha,\alpha^{\prime}}\ln\frac{w^{(\nu)}_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})\,p_{\alpha^{\prime}}(t)}{w^{(\nu)}_{\alpha^{\prime}\alpha}(\bm{\lambda}_{t})\,p_{\alpha}(t)}\,w^{(\nu)}_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})\,p_{\alpha^{\prime}}(t)=\sum\limits_{\nu=1}^{L}\sum\limits_{\bm{N},\bm{N}^{\prime}}\ln\frac{W^{(\nu)}_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda}_{t})\,P_{\bm{N}^{\prime}}(t)}{W^{(\nu)}_{\bm{N}^{\prime}\bm{N}}(\bm{\lambda}_{t})\,P_{\bm{N}}(t)}\,W^{(\nu)}_{\bm{N}\bm{N}^{\prime}}(\bm{\lambda}_{t})\,P_{\bm{N}^{\prime}}(t)=\dot{\Sigma}(t)\geq
0.$ (81)

##  IV Macroscopic Theory

###  IV.1 Macroscopic Fluctuations

Thus far, we have established two equivalent representations of the stochastic
dynamics above, the microscopic and mesoscopic representation. We furthermore
identified the conditions under which the thermodynamics at these levels
coincide. In this section, the question of how to infer the fluctuations in
the macroscopic limit, $N\to\infty$, will be addressed. To shed light on this
question, we will employ the Martin-Siggia-Rose formalism Martin  _et al._
(1973); Weber and Frey (2017) which equivalently represents the Markovian jump
process via a path integral. As will be demonstrated in the following, this
path-integral formalism allows to establish a fluctuating description valid at
macroscopic scales in the large deviation sense Touchette (2009), that is for
fluctuations that scale exponentially with the number of units $N$.

For better readability, we omit a detailed presentation of the elementary
concepts underlying the construction of the path integral and refer to Refs.
Ritort (2004); Suárez  _et al._ (1995); Lazarescu  _et al._ (2019); Vroylandt
_et al._ (2019) where this formalism has been used in a thermodynamic context.
The mesoscopic generating function $G(\gamma_{{}_{O}},t)$ associated with a
mesoscopic stochastic observable $O[\bm{M}_{(\tau)},t]$ within the path
integral representation generically reads

$\displaystyle\begin{aligned}
G(\gamma_{{}_{O}},t)&=\\!\\!\int\\!\\!\mathcal{D}[\bm{N}]\\!\int\\!\\!\mathcal{D}[\bm{\pi}]\;\exp\\!\Bigg{\\{}\\!\int\limits_{0}^{t}\mathrm{d}t^{\prime}\Big{[}\\!-\\!\bm{\pi}(t^{\prime})\\!\cdot\\!\dot{\bm{N}}(t^{\prime})\\!+\\!H_{\gamma_{{}_{O}}}[\bm{N}(t^{\prime}),\bm{\pi}(t^{\prime})]\\!-\\!\gamma_{{}_{O}}\dot{\bm{\lambda}}_{t^{\prime}}\\!\cdot\\!\left[\nabla_{\bm{\lambda}_{t^{\prime}}}\\!O_{\bm{N}(t^{\prime})}\right]\\!-\\!\gamma_{{}_{O}}\mathrm{d}_{t^{\prime}}O_{\bm{N}(t^{\prime})}\Big{]}\Bigg{\\}}P_{\bm{N}}(0)\\\
&\equiv\\!\\!\int\\!\\!\mathcal{D}[\bm{N}]\\!\int\\!\\!\mathcal{D}[\bm{\pi}]\;\exp\Big{\\{}\mathcal{L}_{\gamma_{{}_{O}}}[\bm{N}(t^{\prime}),\bm{\pi}(t^{\prime})]\Big{\\}},\end{aligned}$
(82)

where $\mathcal{D}[\bm{X}]$ denotes the path-integral measure for the function
$\bm{X}$. The quantity $\bm{\pi}$ is the conjugated field and can be
physically interpreted as the instantaneous counting field for variations in
the mesostates $\mathrm{d}\bm{N}$. Moreover, the biased action functional
$\mathcal{L}_{\gamma_{{}_{O}}}[\bm{N},\bm{\pi}]$ consists of the kinetic term
$-\bm{\pi}\,\dot{\bm{N}}$, the biased Hamiltonian that accounts for the
current-like contributions to $G(\gamma_{{}_{O}},t)$,

$\displaystyle
H_{\gamma_{{}_{O}}}[\bm{N}(t^{\prime}),\bm{\pi}(t^{\prime})]=\sum\limits_{\nu=1}^{L}\sum\limits_{i,j=1}^{q}\left\\{\exp\big{[}\pi_{i}(t^{\prime})-\pi_{j}(t^{\prime})\big{]}\;\exp\big{[}-\gamma_{{}_{O}}O_{ij}^{(\nu)}(\bm{N}(t^{\prime}))\big{]}-1\right\\}W_{ij}^{(\nu)}(\bm{\lambda}_{t^{\prime}},\bm{N}(t^{\prime})),$
(83)

of a contribution due to the nonautonomous driving

$\displaystyle-\gamma_{{}_{O}}\int\limits_{0}^{t}\mathrm{d}t^{\prime}\,\dot{\bm{\lambda}}_{t^{\prime}}\cdot\left[\nabla_{\bm{\lambda}_{t^{\prime}}}\,O_{\bm{N}(t^{\prime})}\right],$
(84)

of a state-like contribution

$\displaystyle-\gamma_{{}_{O}}\int\limits_{0}^{t}\mathrm{d}t^{\prime}\;\mathrm{d}_{t^{\prime}}O_{\bm{N}}(t^{\prime})=-\gamma_{{}_{O}}[O_{\bm{N}_{{}_{M}}}(t)-O_{\bm{N}_{{}_{0}}}(0)],$
(85)

and of the initial condition $\ln P_{\bm{N}}(0)$. The quantities
$O_{ij}^{(\nu)}(\bm{N})$ and $W_{ij}^{(\nu)}(\bm{\lambda},\bm{N})$ are the
change of the fluctuating mesoscopic observable $O$ and the mesoscopic
transition rate, respectively, along a jump of the trajectory away from the
mesostate $\bm{N}$ that, at the unit-state level, corresponds to a transition
from state $j$ to $i$ induced by the reservoir $\nu$. For vanishing bias,
$\gamma_{{}_{O}}=0$, Eq. (82) reduces to the path-integral representation of
the path probability in the mesoscopic space.

We now rescale the size-extensive state variables to express them in terms of
the size-intensive density $\bm{\overline{n}}\equiv\bm{N}/N$. Using the
Stirling approximation

$\displaystyle\ln N!=N\ln N-N+\mathbb{O}(\ln N),$ (86)

we find with Eqs. (10) and (19) that the size-extensive mesoscopic internal
entropy can be rewritten as follows,

$\displaystyle\frac{S^{int}_{\bm{N}}}{N}=\sum\limits_{i=1}^{q}\left[\overline{n}_{i}\ln
N-\overline{n}_{i}\right]-\sum\limits_{i=1}^{q}\left[\overline{n}_{i}\ln
N_{i}-\overline{n}_{i}\right]+\mathbb{O}\left(\frac{\ln
N}{N}\right)=\underbrace{-\sum\limits_{i=1}^{q}\overline{n}_{i}\ln\overline{n}_{i}}_{\equiv\mathcal{S}^{int}_{\bm{\overline{n}}}}+\,\mathbb{O}\left(\frac{\ln
N}{N}\right),$ (87)

where $\mathbb{O}(\cdot)$ gives the order of magnitude of the error made by
the approximation. Using the last equation and Eq. (2), the size-extensive
part of the mesoscopic free energy (18) reads

$\displaystyle\frac{A^{(\nu)}_{\bm{N}}(\bm{\lambda}_{t})}{N}=\underbrace{\sum_{i=1}^{q}\Bigg{(}\overline{n}_{i}\epsilon_{i}(\bm{\lambda}_{t})+\frac{u_{i}(\bm{\lambda}_{t})}{2}\,\overline{n}_{i}^{2}+\sum_{j}u_{ij}(\bm{\lambda}_{t})\overline{n}_{i}\,\overline{n}_{j}\Bigg{)}}_{\equiv\mathcal{E}_{\bm{\overline{n}}}(\bm{\lambda}_{t})}+\frac{1}{\beta^{(\nu)}}\sum_{i=1}^{q}\overline{n}_{i}\log{\overline{n}_{i}}+\mathbb{O}\left(\frac{\ln
N}{N}\right)\equiv\mathcal{A}_{\bm{\overline{n}}}^{(\nu)}(\bm{\lambda}_{t})+\mathbb{O}\left(\frac{\ln
N}{N}\right).$ (88)

In order to proceed, we now make the crucial assumption that the functional
form of the leading order of the mesoscopic rates in $N$ is invariant under
scaling by $1/N$, _i.e._ the size-extensive contributions of the mesoscopic
rates are exactly homogeneous,

$\displaystyle\frac{W_{ij}^{(\nu)}(\bm{\lambda}_{t},\bm{N})}{N}=k_{ij}^{(\nu)}(\bm{\lambda}_{t},\bm{\overline{n}})\;\overline{n}_{j}+\mathbbm{o}(1),$
(89)

where $\mathbbm{o}(1)$ refers to all terms that are subextensive in $N$. From
the homogeneity property of the leading order of the mesoscopic rates and the
change in the size-extensive part of the free energy for a transition from
unit state $j\to i$,

$\displaystyle
A^{(\nu)}_{\bm{N}}(\bm{\lambda}_{t})-A^{(\nu)}_{\bm{N}^{\prime}}(\bm{\lambda}_{t})\overset{\begin{subarray}{c}\bm{N}^{\prime}\to\bm{N}\\\
j\to
i\end{subarray}}{\equiv}(\partial_{\overline{n}_{i}}-\partial_{\overline{n}_{j}})\mathcal{A}_{\bm{\overline{n}}}(\bm{\lambda}_{t})+\mathbb{O}\left(1/N\right),$
(90)

follows that the macroscopic, size-intensive transition rates
$k_{ij}^{(\nu)}(\bm{\lambda}_{t},\bm{\overline{n}})\;\overline{n}_{j}$
satisfy, up to non-extensive terms in the mesoscopic free energy, the
following local detailed balance condition, _i.e._

$\displaystyle\begin{aligned}
&\ln\frac{W_{ij}^{(\nu)}(\bm{\lambda}_{t},\bm{N})}{W_{ji}^{(\nu)}(\bm{\lambda}_{t},\bm{N})}=\ln\frac{k_{ij}^{(\nu)}(\bm{\lambda}_{t},\bm{\overline{n}})\;\overline{n}_{j}}{k_{ji}^{(\nu)}(\bm{\lambda}_{t},\bm{\overline{n}})\;\overline{n}_{i}}+\mathbb{O}\left(1/N\right)=-\beta^{(\nu)}\Big{[}\underbrace{(\partial_{\overline{n}_{i}}-\partial_{\overline{n}_{j}})\mathcal{A}_{\bm{\overline{n}}}(\bm{\lambda}_{t})}_{(\partial_{\overline{n}_{i}}-\partial_{\overline{n}_{j}})\mathcal{E}_{\bm{\overline{n}}}(\bm{\lambda}_{t})-\frac{1}{\beta^{(\nu)}}\ln\frac{\overline{n}_{j}}{\overline{n}_{i}}}-f_{ij}^{(\nu)}\Big{]}+\mathbb{O}\left(1/N\right)\\\
&=\\!-\beta^{(\nu)}\Big{\\{}\underbrace{\underbrace{\epsilon_{i}(\lambda_{t})\\!-\\!\epsilon_{j}(\lambda_{t})+[u_{i}(\lambda^{\prime}_{t})\,\overline{n}_{i}\\!-\\!u_{j}(\lambda^{\prime}_{t})\,\overline{n}_{j}]+\sum\limits_{k\neq
i}u_{ik}(\lambda^{\prime}_{t})\overline{n}_{k}(t)\\!-\\!\sum\limits_{k\neq
j}u_{jk}(\lambda^{\prime}_{t})\overline{n}_{k}(t)}_{\equiv\mathcal{E}_{ij}^{(\nu)}\big{(}\bm{\lambda}_{t},\bm{\overline{n}}\big{)}}\\!-\\!\frac{1}{\beta^{(\nu)}}\ln\frac{\overline{n}_{j}}{\overline{n}_{i}}}_{\equiv\mathcal{A}_{ij}^{(\nu)}\big{(}\bm{\lambda}_{t},\bm{\overline{n}}\big{)}}-f_{ij}^{(\nu)}\Big{\\}}+\mathbb{O}\left(1/N\right)\\!.\end{aligned}$
(91)

Next, the scaled mesoscopic entropy production with bounding Gibbs states (75)
expressed in terms of the size-extensive fluctuations reads as follows,

$\displaystyle\frac{\delta\Sigma[\bm{m}_{(\tau)},t]}{N}=\beta^{(1)}\big{[}\delta\mathcal{W}_{\bm{\lambda}}[\bm{m}_{(\tau)},t]-\Delta\mathcal{A}^{eq}_{1}\big{]}+\sum_{\nu=1}^{L}\big{\\{}\beta^{(\nu)}\delta\mathcal{W}_{\bm{f}}^{(\nu)}[\bm{m}_{(\tau)},t]+\big{[}\beta^{(1)}-\beta^{(\nu)}\big{]}\delta\mathcal{E}^{(\nu)}[\bm{m}_{(\tau)},t]\big{\\}}+\mathbb{O}\left(\tfrac{\ln
N}{N}\right),$ (92)

where $\delta\mathcal{W}_{\bm{\lambda}}=\lim_{N\to\infty}\delta
W_{\bm{\lambda}}/N$,
$\Delta\mathcal{A}_{1}^{eq}(\bm{\lambda})=\lim_{N\to\infty}A^{eq}_{1}(\bm{\lambda})/N$,
$\delta\mathcal{W}_{\bm{f}}^{(\nu)}=\lim_{N\to\infty}\delta
W_{\bm{f}}^{(\nu)}/N$ and $\delta\mathcal{E}^{(\nu)}=\lim_{N\to\infty}\delta
E^{(\nu)}/N$ are the size-intensive scaled nonautonomous work current, the
change in size-intensive scaled equilibrium free-energy with respect to the
reference reservoir $\nu=1$, the size-intensive scaled autonomous work current
and the size-intensive scaled energy current, respectively, in the macroscopic
limit.

Collecting results, inserting the expression for the stochastic entropy
production with bounding Gibbs states (75) into the generic path-integral
representation for a mesoscopic generating function (82), and expressing the
latter in terms of the dominant size-extensive terms, we get

$\displaystyle\begin{aligned}
&G(\bm{\gamma},t)=\int\mathcal{D}[\bm{\overline{n}}]\int\mathcal{D}[\bm{\pi}]\;P_{\bm{\overline{n}}_{{}_{0}}}^{eq}(\bm{\lambda}_{0})\cdot\exp\Bigg{\\{}N\int\limits_{0}^{t}\mathrm{d}t^{\prime}\Bigg{[}\\!-\\!\gamma_{{}_{\bm{\lambda}}}\beta^{(1)}\dot{\bm{\lambda}}_{t^{\prime}}\cdot\big{[}\nabla_{\bm{\lambda}_{t^{\prime}}}\mathcal{E}_{\bm{\overline{n}}}(\bm{\lambda}_{t^{\prime}})\big{]}+\sum\limits_{i=1}^{q}\Big{\\{}-\pi_{i}(t^{\prime})\dot{\overline{n}}_{i}(t^{\prime})\\\
&+\\!\sum\limits_{\nu=1}^{L}\sum\limits_{j=1}^{q}\\!\Big{[}\\!\exp\Big{\\{}\pi_{i}(t^{\prime})\\!-\\!\pi_{j}(t^{\prime})\\!-\\!\gamma_{{}_{\bm{f}}}^{(\nu)}\beta^{(\nu)}f_{ij}^{(\nu)}\\!-\\!\gamma_{\mathcal{E}}^{(\nu)}[\beta^{(1)}\\!-\\!\beta^{(\nu)}]\,\mathcal{E}_{ij}^{(\nu)}\big{(}\bm{\lambda}_{t^{\prime}},\bm{\overline{n}}(t^{\prime})\big{)}\\!\Big{\\}}\\!-\\!1\Big{]}k_{ij}^{(\nu)}\big{(}\bm{\lambda}_{t^{\prime}},\bm{\overline{n}}(t^{\prime})\big{)}\,\overline{n}_{j}(t^{\prime})\Big{\\}}\\!+\\!\mathbbm{o}(1)\Bigg{]}\\!\Bigg{\\}}\\\
&\equiv\int\mathcal{D}[\bm{\overline{n}}]\int\mathcal{D}[\bm{\pi}]\;\exp\Big{\\{}N\Big{[}\mathcal{L}_{\bm{\gamma}}[\bm{\overline{n}}(t^{\prime}),\bm{\pi}(t^{\prime})]+\mathbbm{o}(1)\Big{]}\Big{\\}},\end{aligned}$
(93)

with the shorthand notation from Eq. (73) and with $\gamma$ that denotes a
vector of fields $\gamma_{\mathcal{O}}$ that counts the scaled observables,
$\mathcal{O}=\lim_{N\to\infty}O/N$. Moreover, we rewrote the mesoscopic
initial equilibrium distribution in terms of size-extensive free energies as
follows

$\displaystyle
P^{eq}_{\bm{N}}(\bm{\lambda}_{0})=\underbrace{\exp\Big{\\{}N\Big{[}\\!-\\!\beta^{(1)}\big{[}\mathcal{A}^{(1)}_{\mathbf{\overline{n}}}(\bm{\lambda}_{0})-\mathcal{A}^{eq}_{1}(\bm{\lambda}_{0})\big{]}}_{\equiv
P^{eq}_{\bm{\overline{n}}}(\bm{\lambda}_{0})}+\mathbb{O}\left(\tfrac{\ln
N}{N}\right)\Big{]}\Big{\\}}.$ (94)

As demonstrated in appendix C, the generating function (93) satisfies, up to
non-extensive fluctuations in the system size $N$, the symmetry relation

$\displaystyle
G(\bm{\gamma},t)=\tilde{G}(\tilde{\bm{\gamma}},t)\;\exp\big{\\{}N\big{[}-\beta^{(1)}\Delta\mathcal{A}^{eq}_{1}(\bm{\lambda})+\mathbbm{o}(1)\big{]}\big{\\}}.$
(95)

In the macroscopic limit, $N\to\infty$, there is a single trajectory that
carries all the weight of all possible paths contributing to the path integral
(82). This trajectory maximizes the size-intensive action functional in Eq.
(93),
$\mathrm{max}\;\mathcal{L}_{\bm{\gamma}}[\bm{\overline{n}},\bm{\pi}]=\mathcal{L}_{\bm{\gamma}}[\bm{\overline{n}}^{*},\bm{\pi}^{*}]$,
and its coordinates are therefore determined as follows

$\displaystyle\frac{\delta\mathcal{L}_{\bm{\gamma}}[\bm{\overline{n}},\bm{\pi}]}{\delta\bm{\pi}}\Big{|}_{\bm{\overline{n}}^{*},\bm{\pi}^{*}}=0,\qquad\frac{\delta\mathcal{L}_{\bm{\gamma}}[\bm{\overline{n}},\bm{\pi}]}{\delta\bm{\overline{n}}}\Big{|}_{\bm{\overline{n}}^{*},\bm{\pi}^{*}}=0,$
(96)

where
$\bm{\overline{n}}^{*}(\bm{\gamma})\equiv\lim_{N\to\infty}\bm{N}^{*}(\bm{\gamma})/N$
is the most likely biased and continuous density. To ease notation, we will
omit the “$*$” in the following. We consequently obtain via Eq. (82) the size-
scaled cumulant generating function

$\displaystyle\mathcal{G}(\bm{\gamma},t)=\lim_{N\to\infty}\frac{1}{N}\,\ln
G(\bm{\gamma},t)=\mathcal{L}_{\bm{\gamma}}[\bm{\overline{n}},\bm{\pi}].$ (97)

Crucially, the macroscopic limit taken in the definition of the the scaled
cumulant generating function eliminates the non-extensive terms in Eq. (95),
_i.e._ the scaled cumulant generating function associated with the entropy
production (75) satisfies a symmetry that is formally equivalent to the one
exhibited by the mesoscopic generating functions (72). Explicitly, we have

$\displaystyle\mathcal{G}(\bm{\gamma},t)=\tilde{\mathcal{G}}(\tilde{\bm{\gamma}},t)-\beta^{(1)}\Delta\mathcal{A}^{eq}_{1}(\bm{\lambda}),$
(98)

which is a symmetry for the macroscopic fluctuations exponentially dominating
the mesoscopic dynamics. The last equation immediately stipulates the
existence of a finite-time detailed fluctuation theorem in the spirit of Eq.
(74) that asymptotically holds in the macroscopic limit,

$\displaystyle\lim_{N\to\infty}\frac{1}{N}\ln\frac{P\Big{(}\beta^{(1)}\delta
W_{\bm{\lambda}}\,,\,\\{\delta J^{(\nu)}_{\bm{f}}\\}\,,\,\\{\delta
J^{(\nu)}_{E}\\}\Big{)}}{\tilde{P}\Big{(}-\beta^{(1)}\delta
W_{\bm{\lambda}}\,,\,\\{-\delta J^{(\nu)}_{\bm{f}}\\}\,,\,\\{-\delta
J^{(\nu)}_{E}\\}\Big{)}}=\beta^{(1)}\big{[}\delta\mathcal{W}_{\bm{\lambda}}-\Delta\mathcal{A}^{eq}_{1}\big{]}+\sum\limits_{\nu=1}^{L}\big{[}\beta^{(\nu)}\delta\mathcal{W}_{\bm{f}}^{(\nu)}+\big{[}\beta^{(1)}-\beta^{(\nu)}\big{]}\delta\mathcal{E}^{(\nu)}\big{]}\,.$
(99)

The existence of the finite-time detailed fluctuation theorem (99) is an
important result as it ensures the thermodynamic consistency of the path-
integral approach at macroscopic scales, _i.e._ for fluctuations that are
extensive in and thus scale exponentially with the system size $N$.

We stress that the finding of the macroscopic symmetry (98) and the
macroscopic detailed fluctuation theorem detailed is nontrivial since it is
mathematically not obvious that the symmetry at microscopic (69) and
mesoscopic (72) scales is also asymptotically preserved at macroscopic scales
in spite of discarding subextensive contributions to the current statistics.
It is however important to recall that these results rely on the assumption
that the leading order of the mesoscopic transitions rates in $N$ is
homogeneous (89).

###  IV.2 Mean-Field Description

####  IV.2.1 Mean-Field Dynamics

We proceed by formulating the dynamics and thermodynamics in the macroscopic
mean-field limit, where the system behaves deterministically. First we note
that for an unbiased dynamics, $\bm{\gamma}=0$, that the extremal values of
the auxiliary field are $\bm{\pi}=0$. Thus, the action functional (93) needs
only to be maximized with respect to the density resulting into the following
Hamiltonian equations of motion

$\displaystyle\frac{\delta\mathcal{L}[\bm{\overline{n}},\bm{\pi}]}{\delta\bm{\pi}}\Bigg{|}_{\bm{\pi}=0}=0\;\Leftrightarrow\;\dot{\bm{\overline{n}}}=\frac{\delta
H[\bm{\overline{n}},\bm{\pi}]}{\delta\bm{\pi}}\Bigg{|}_{\bm{\pi}=0}.$ (100)

The Hamiltonian equations of motion correspond to the mean-field equation
governing the deterministic dynamics of the most likely occupation (mean-
field) density and read explicitly,

$\displaystyle\partial_{t}\overline{n}_{i}(t)=\sum\limits_{j=1}^{q}k_{ij}(\bm{\lambda}_{t})\,\overline{n}_{j}(t)\,,\quad\sum\limits_{i=1}^{q}\overline{n}_{i}(t)=1\,,$
(101)

with the mean-field transition rate matrix as defined in Eq. (89) and
evaluated at the most likely mean-field density (100),

$\displaystyle k_{ij}(\bm{\lambda}_{t})\equiv
k_{ij}(\bm{\lambda}_{t},\bm{\overline{n}})=\sum\limits_{\nu=1}^{L}k_{ij}^{(\nu)}(\bm{\lambda}_{t},\bm{\overline{n}})\,,$
(102)

that is stochastic, $\sum_{i}k_{ij}(\bm{\lambda}_{t})=0$, and whose
contributions corresponding to the different heat reservoirs obey a mean-field
local detailed balance (91) ensuring thermodynamic consistency at the mean-
field level. We note that because of probability conservation the nonlinear
mean-field equation is $q-1$ dimensional.

####  IV.2.2 Mean-Field First And Second Law

Analogously to Sec. III.4, we now want to formulate the first and second law
in the macroscopic mean-field limit. Following a similar procedure as for the
derivation of Eq. (101), we obtain from Eqs. (82) and (83) for the mean-field
energy,

$\displaystyle\mathcal{E}(t)$
$\displaystyle=\sum\limits_{i=1}^{q}\mathcal{E}_{i}(\bm{\lambda}_{t})\,\overline{n}_{i}(t),\quad\mathcal{E}_{i}(\bm{\lambda}_{t})\equiv\partial_{\overline{n}_{i}}\mathcal{E}_{\bm{\overline{n}}}(\bm{\lambda}_{t})=\epsilon_{i}(\lambda_{t})+u_{i}(\lambda^{\prime}_{t})+\sum\limits_{k\neq
i}u_{ik}(\lambda^{\prime}_{t})\overline{n}_{k}(t),$ (103)

whose time-derivative constitutes the first law in the macroscopic limit,

$\displaystyle\mathrm{d}_{t}\mathcal{E}(t)=\dot{\mathcal{Q}}(t)+\dot{\mathcal{W}}(t),$
(104)

with the mean-field heat and work current,

$\displaystyle\dot{\mathcal{Q}}(t)$
$\displaystyle=\sum\limits_{\nu=1}^{L}\sum\limits_{i,j=1}^{q}\left[\mathcal{E}_{i}(\bm{\lambda}_{t})-\mathcal{E}_{j}(\bm{\lambda}_{t})-f^{(\nu)}_{ij}\right]\,k_{ij}^{(\nu)}(\bm{\lambda}_{t})\;\overline{n}_{j}(t)=\sum\limits_{\nu=1}^{L}\sum\limits_{i,j=1}^{q}-\frac{1}{\beta^{(\nu)}}\,\ln\Bigg{[}\frac{k_{ij}^{(\nu)}(\bm{\lambda}_{t})}{k_{ji}^{(\nu)}(\bm{\lambda}_{t})}\,\Bigg{]}\;k_{ij}^{(\nu)}(\bm{\lambda}_{t})\;\overline{n}_{j}(t)$
(105) $\displaystyle\dot{\mathcal{W}}(t)$
$\displaystyle=\sum_{i=1}^{q}\bigg{\\{}\dot{\bm{\lambda}}_{t}\cdot\nabla_{\bm{\lambda}_{t}}\,\mathcal{E}_{i}(\bm{\lambda}_{t})\;\overline{n}_{i}(t)+\sum\limits_{\nu=1}^{L}\sum\limits_{j=1}^{q}\Big{[}\sum\limits_{k\neq
i}\overline{n}_{i}(t)\,u_{ik}(\lambda^{\prime}_{t})\,k^{(\nu)}_{kj}(\bm{\lambda}_{t})+f^{(\nu)}_{ij}\;k^{(\nu)}_{ij}(\bm{\lambda}_{t})\Big{]}\,\overline{n}_{j}(t)\bigg{\\}}.$
(106)

A closer inspection of Eqs. (80) reveals that in the deterministic macroscopic
limit the stochastic (Shannon) part of the mesoscopic system entropy vanishes
and only the internal entropy of the mesostates (19) remains finite. Thus, we
conclude from Eq. (87) that the mean-field entropy reads

$\displaystyle\mathcal{S}(t)\equiv\mathcal{S}^{int}_{\bm{\overline{n}}}=-\sum\limits_{i=1}^{q}\overline{n}_{i}(t)\,\ln\overline{n}_{i}(t).$
(107)

The entropy in deterministic many-body systems therefore originates from the
Boltzmann entropies related to the internal structure of the mesostates.
Remarkably, the deterministic mean-field entropy takes the form of a Shannon
entropy for the mean-field density.

Next, Equations (81) and (107) imply the second law in the macroscopic limit

$\displaystyle\dot{\mathcal{S}}_{i}(t)=\sum\limits_{\nu=1}^{L}\sum\limits_{i,j=1}^{q}\ln\frac{k^{(\nu)}_{ij}(\bm{\lambda}_{t})\,\overline{n}_{j}(t)}{k^{(\nu)}_{ji}(\bm{\lambda}_{t})\,\overline{n}_{i}(t)}\,k^{(\nu)}_{ij}(\bm{\lambda}_{t})\,\overline{n}_{j}(t)=\dot{\mathcal{S}}(t)-\dot{\mathcal{S}}_{e}(t)\geq
0.$ (108)

Hence the microscopic and mesoscopic observables in Eqs. (76)–(81) converge to
the corresponding mean-field ones in Eq. (103)–(108) if the macroscopic limit
is taken,

$\displaystyle\lim_{N\to\infty}\frac{1}{N}\dot{O}(t)=\dot{\mathcal{O}}(t),\qquad
O=E,Q,W,S,S_{e},\Sigma,$ (109)

where we recall that the mesoscopic representations for $O=S,\Sigma$ are only
valid if the microstates inside each mesostate are equiprobable.

This constitutes our main result: For thermodynamically consistent and
discrete many-body systems with all-to-all interactions there is an exact
coarse-graining (14) of the microscopic stochastic dynamics towards a
mesoscopic one that is fully characterized by the system occupation. In the
macroscopic limit, $N\to\infty$, the stochastic dynamics asymptotically
converges to a deterministic and nonlinear macroscopic (mean-field) master
equation (101). Hence the stochastic dynamics can be equivalently represented
across microscopic and mesoscopic scales and asymptotically on macroscopic
scales as $N\to\infty$. Furthermore, the thermodynamics can be equivalently
formulated at microscopic and mesoscopic scales if the microstates inside each
mesostate are equiprobable (25). The thermodynamic consistency at each of the
two levels is encoded in the respective detailed fluctuation theorem, see Eqs.
(68) and (74). Using a path-integral representation of the stochastic
(thermo)dynamics à la Martin-Siggia Rose, the fluctuations which scale
exponentially with the system size also satisfy a detailed fluctuation theorem
(99) and are therefore also thermodynamically consistent.

##  V Example

To illustrate the methodology developed in the preceding Sec. IV we consider a
semi-analytically solvable autonomous Ising model which exhibits a
nonequilibrium phase transition, thus representing a suitable model to
demonstrate the utility of the aforementioned methods. To this end, let us
consider $N\to\infty$ spins with flat energy landscapes,
$\epsilon_{1}=\epsilon_{2}$, that globally interact via a pair potential $u/N$
if they occupy the same spin state $i=1,2$. The system is in contact with two
heat reservoirs at different inverse temperatures $\beta^{h}$ and $\beta^{c}$
with $\beta^{h}<\beta^{c}$. Related models with a similar phenomenology can be
found in Refs. Garrido  _et al._ (1987); Blote  _et al._ (1990); Bauer and
Cornu (2018).

According to Eq. (101), the mean-field dynamics is governed by the following
nonlinear rate equation

$\displaystyle\partial_{t}\overline{n}_{i}$
$\displaystyle=-\Big{(}k_{ji}^{(h)}+k_{ji}^{(c)}\Big{)}\overline{n}_{i}+\Big{(}k_{ij}^{(h)}+k_{ij}^{(c)}\Big{)}\overline{n}_{j}=-k_{ji}\,\overline{n}_{i}+k_{ij}\,\overline{n}_{j},\quad
i,j=1,2\;,$ (110)

with the mean-field transition rates which we assume to be of Arrhenius form

$\displaystyle
k_{ij}^{(\nu)}=\Gamma\,\exp\Big{[}-\frac{\beta^{(\nu)}}{2}u(\overline{n}_{i}-\overline{n}_{j})\Big{]},\quad\nu=c,h,$
(111)

with the constant kinetic prefactor $\Gamma$ that sets the time-scale of the
Markov jump process. We note that the mean-field dynamics (110) is effectively
a one-dimensional equation since we have $\overline{n}_{2}=1-\overline{n}_{1}$
because the number of spins is conserved. We can immediately read off the
stationary solution $\overline{n}_{i}^{s}=1/2,\,i=1,2$ for Eq. (110). The
stability of this symmetric fixed point is encoded in the spectrum of the
linearized Jacobian,
$\bm{A}_{ij}\equiv[\partial(\partial_{t}\overline{n}_{i})/\partial\overline{n}_{j}]|_{\overline{n}_{i,j}=1/2}$,
which can be readily determined as follows

$\displaystyle\lambda_{1}=0,\quad\lambda_{2}=-\Gamma\big{[}4+u\big{(}\beta^{(h)}+\beta^{(c)}\big{)}\big{]}.$
(112)

The zero eigenvalue $\lambda_{1}$ reflects that the rank of the Jacobian is
smaller than its dimension due to the constraint
$\sum_{i}\partial_{t}\overline{n}_{i}=0$. More strikingly, the second
eigenvalue $\lambda_{2}$ changes its sign for attractive interactions, $u<0$,
at the critical temperatures

$\displaystyle 4+u\big{(}\beta^{(h)}_{c}+\beta^{(c)}_{c}\big{)}=0,$ (113)

indicative of a supercritical pitchfork bifurcation that destabilizes the
symmetric fixed point into two asymmetric fixed points as can be seen in Fig.
3. This density plot depicts the stationary solution $\overline{n}_{1}^{s}$ as
a function of all physical initial conditions $\overline{n}_{1}(0)$ and for
different cold temperatures $\beta^{(c)}$ while $\beta^{(h)}\equiv 1$ and
$u=-1$ are kept constant. As can be observed, the symmetric fixed point is
stable for $\beta^{(c)}<\beta^{(c)}_{c}=3$. In contrast, for lower
temperatures $\beta^{(c)}>\beta^{(c)}_{c}=3$ the symmetric fixed point is
unstable and the system dynamics goes to one of the two asymmetric stable
fixed points depending on the basin of attraction in which the initial
condition lies. These two stable fixed points are related to each other via
permutations of their coordinates, in agreement with the invariance of the
mean-field Eq. (110) under a permutation operation. The phenomenology observed
in Fig. 3 can be physically seen as follows. In the high-temperature limit the
system behaves entropically, thus occupying the symmetric fixed point.
Conversely, in the low-temperature limit the system behaves energetically,
thus exhibiting two asymmetric fixed points that converge to the two energy
ground states, that is $\overline{n}_{1}=1,\overline{n}_{2}=0$ and
$\overline{n}_{1}=0,\overline{n}_{2}=1$, as $\beta\to\infty$. For isothermal
systems, Eq. (113) implies the critical point $\beta_{c}=-2/u$. This is in
agreement with the $q$-dependent universal critical temperature,
$\beta_{c}(q)=-q/u$ for isothermal and all-to-all interacting $q$-state clock
models derived in Ref. Herpich and Esposito (2019). We add that the isothermal
system displays a first-order equilibrium phase transition.

Figure 3: Density plot of the stationary solution $\overline{n}_{1}^{s}$ for
different temperatures $\beta^{(c)}$ and all physical initial conditions
$\overline{n}_{1}(0)$. We choose the following values for the parameters
$\Gamma=0.1,\beta^{(h)}=1,u=-1$ so that $\beta^{(c)}_{c}=3$ as indicated by
the vertical dotted line.

We now return to the non-isothermal case and consider the fluctuating quantity
in Eq. (75) that for the autonomous Ising model simplifies to

$\displaystyle\delta\Sigma[\bm{m}_{(\tau)},t]=\sum\limits_{\nu=h,c}\big{[}\beta^{(h)}-\beta^{(\nu)}\big{]}\delta
E^{(\nu)}[\bm{m}_{(\tau)},t]\big{\\}},\quad\delta
E^{(\nu)}[\bm{m}_{(\tau)},t]=u\int\limits_{0}^{t}\mathrm{d}t^{\prime}\sum\limits_{j=1}^{M}\delta(\nu-\nu_{j})\delta(t^{\prime}-\tau_{j})[n_{j}-n_{j-1}].$
(114)

According to Eq. (74), our model system therefore satisfies a finite-time
detailed fluctuation theorem for the time-integrated energy current. Using the
path-integral formalism introduced in Sec. IV, we however observe that
analytical progress is difficult at finite time as it would require to solve
the full extremization problem (96) which is analytically not possible.
Instead, we therefore resort to the stationary case which considerable
simplifies the problem of finding the dominant trajectory among all paths
contributing to the path integral. The biased Hamiltonian (83) in the path-
integral formulation of the generating function (93) associated with the
stochastic observable in the last equation reads

$\displaystyle\begin{aligned}
H_{\gamma^{(c)}_{{}_{\mathcal{E}}}}[\bm{\overline{n}},\bm{\pi}]&=k_{21}^{(h)}\,\overline{n}_{1}\big{[}\exp\big{(}\pi_{2}-\pi_{1}\big{)}-1\big{]}+k_{21}^{(c)}\,\overline{n}_{1}\Big{[}\exp\big{(}\pi_{2}-\pi_{1}\big{)}\exp\big{\\{}\gamma
u[\beta^{(h)}-\beta^{(c)}](\overline{n}_{2}-\overline{n}_{1})\big{\\}}-1\Big{]}\;+\\\
&+k_{12}^{(h)}\,\overline{n}_{2}\big{(}\exp\big{[}-(\pi_{2}-\pi_{1})\big{]}-1\big{)}+k_{12}^{(c)}\,\overline{n}_{2}\Big{(}\exp\big{[}-(\pi_{2}-\pi_{1})\big{]}\exp\big{\\{}-\gamma
u[\beta^{(h)}-\beta^{(c)}](\overline{n}_{2}-\overline{n}_{1})\big{\\}}-1\Big{)}.\end{aligned}$
(115)

At steady state, the Hamiltonian equations of motion resulting from the
extremization of the action functional in Eq. (96) read

$\displaystyle\partial_{\overline{n}_{i}}H_{\gamma^{(c)}_{{}_{\mathcal{E}}}}[\bm{\overline{n}},\bm{\pi},\lambda_{\overline{n}},\lambda_{\pi}]=0,\quad\partial_{\pi_{i}}H_{\gamma^{(c)}_{{}_{\mathcal{E}}}}[\bm{\overline{n}},\bm{\pi},\lambda_{\overline{n}},\lambda_{\pi}]=0,\quad
i=1,2,$ (116)

where we added the Lagrangian multipliers $\lambda_{\overline{n}}$ and
$\lambda_{\pi}$ to enforce the spin conservation,
$\overline{n}_{1}+\overline{n}_{2}-1=0$ and $\pi_{1}+\pi_{2}=0$. The extremal
value for $\pi_{1}$ can be solved analytically,

$\displaystyle\pi_{1}\\!=\\!\frac{1}{4}\ln\\!\left(\\!\frac{\overline{n}_{1}}{\overline{n}_{1}-1}\\!\cdot\\!\frac{\exp\big{[}\beta^{(h)}u(2\overline{n}_{1}-1)\big{]}+\exp\big{\\{}\frac{u}{2}(2\overline{n}_{1}-1)[\beta^{(c)}\big{(}2\gamma^{(c)}_{{}_{E}}-1\big{)}-\beta^{(h)}\big{(}1+2\gamma^{(c)}_{{}_{E}}\big{)}]\big{\\}}}{1+\exp\big{[}\frac{\beta^{(c)}-\beta^{(h)}}{2}u(2\overline{n}_{1}-1)\big{(}2\gamma^{(c)}_{{}_{E}}-1\big{)}\big{]}}\\!\right)\\!+\\!\mathrm{i}\pi(1+2k),\;k\in\mathbb{Z},$
(117)

and the extremal value $\overline{n}_{1}$ is subsequently determined
numerically. In the $t\to\infty$ limit, the boundary terms in the action
functional become negligible so that the time- and size-scaled cumulant
generating function is asymptotically equal to the biased Hamiltonian
evaluated at the extremal values $\bm{\overline{n}}$ and $\bm{\pi}$,

$\displaystyle\mathcal{G}^{s}\big{(}\gamma^{(c)}_{{}_{\mathcal{E}}}\big{)}=\lim_{t\to\infty}\frac{1}{t}\,\lim_{N\to\infty}\frac{1}{N}\,\ln
G\big{(}\gamma^{(c)}_{{}_{E}},t\big{)}=H^{s}_{\gamma^{(c)}_{{}_{\mathcal{E}}}}[\bm{\overline{n}},\bm{\pi}].$
(118)

The scaled cumulant generating function is plotted in Fig. 4a). We choose the
values $\beta^{(h)}=3,\beta^{(c)}=5,u=-1$ corresponding to the phase where the
mean-field dynamics exhibits two asymmetric stable and a symmetric unstable
fixed point. Similarly, we observe two asymmetric $\gamma$-dependent fixed
points $\overline{n}_{1}(\gamma)$ whose coordinates are related to each other
via a permutation as well as a symmetric fixed point at
$\overline{n}_{1}=1/2$. The regime around 1/2 corresponds to the symmetric
fixed point and thus to a null observable (114). Next, we note that the curve
is symmetric with respect to the value $\gamma=1/2$, thus implying that the
scaled cumulant generating function asymptotically satisfies the symmetry
relation

$\displaystyle\mathcal{G}^{s}\big{(}\gamma^{(c)}_{{}_{\mathcal{E}}}\big{)}=\tilde{\mathcal{G}}^{s}\big{(}1-\gamma^{(c)}_{{}_{\mathcal{E}}}\big{)},$
(119)

which in turn stipulates the existence of a macroscopic steady-state detailed
fluctuation theorem for the time-integrated energy current

$\displaystyle\lim_{t\to\infty}\frac{1}{t}\lim_{N\to\infty}\frac{1}{N}\ln\frac{P\big{(}\delta
J^{(c)}_{E}\big{)}}{\tilde{P}\big{(}-\delta
J^{(c)}_{E}\big{)}}=\delta\mathcal{J}^{(c),s}_{\mathcal{E}},\quad\delta\mathcal{J}^{(c),s}_{\mathcal{E}}=[\beta^{(h)}-\beta^{(c)}]\;\lim_{t\to\infty}\frac{1}{t}\lim_{N\to\infty}\frac{1}{N}\,\delta
E^{(c)}.$ (120)

The existence of the steady-state fluctuation theorem is by no means obvious,
here. In general, the implicit assumption underlying steady-state fluctuation
theorems is that the contribution of the boundary terms related to the initial
and final state of each trajectory are subextensive in time and thus
negligible in the infinite-time limit. There are however situations where this
may not be true, _e.g._ in bistable systems for starting distributions of the
forward and backward process that are located in the different basins of
attraction. Though, in this model the two
$\gamma^{(c)}_{{}_{\mathcal{E}}}$-dependent fixed points are related to each
other via permutation of their coordinates and the statistics of the
corresponding stationary states are thus identical.

Figure 4: The cumulant generating function (118) scaled with time $t$ and size
$N$ as a function of the counting field $\gamma^{(c)}_{{}_{\mathcal{E}}}$ in
a) and the corresponding rate function
$\Phi\big{(}\delta\mathcal{J}^{(c),s}_{\mathcal{E}}\big{)}$ in b). The
parameters are chosen as $\beta^{(h)}=3,\beta^{(c)}=5,u=-1$ so that for
$\gamma^{(c)}_{{}_{\mathcal{E}}}=0$ the stationary mean-field system is in its
energetic phase which has two asymmetric stable fixed points and a symmetric
unstable one.

Figure 4b) shows the rate function
$\Phi\big{(}\delta\mathcal{J}^{(c),s}_{\mathcal{E}}\big{)}$ associated with
the scaled cumulant generating function
$\mathcal{G}^{s}\big{(}\gamma^{(c)}_{{}_{\mathcal{E}}})$ in a). The rate
function is defined as Touchette (2009)

$\displaystyle\Phi\big{(}\delta\mathcal{J}^{(c),s}_{\mathcal{E}}\big{)}=-\lim_{t\to\infty}\frac{1}{t}\lim_{N\to\infty}\frac{1}{N}\ln
P\big{(}\delta J^{(c),s}_{E}\big{)},$ (121)

and is related to its corresponding scaled cumulant generating function via a
Legendre-Fenchel transformation

$\displaystyle\Phi\big{(}\delta\mathcal{J}^{(c),s}_{\mathcal{E}}\big{)}=\underset{\delta\mathcal{J}^{(c),s}_{\mathcal{E}}}{\operatorname{sup}}\,[\gamma^{(c)}_{{}_{\mathcal{E}}}\,\delta\mathcal{J}^{(c),s}_{\mathcal{E}}-\mathcal{G}^{s}\big{(}\gamma^{(c)}_{{}_{\mathcal{E}}})],\qquad\delta\mathcal{J}^{(c),s}_{\mathcal{E}}=\frac{\partial\mathcal{G}^{s}\big{(}\gamma^{(c)}_{{}_{\mathcal{E}}}\big{)}}{\partial\gamma^{(c)}_{{}_{\mathcal{E}}}},$
(122)

where $\operatorname{sup}$ denotes the supremum. As can be seen in Fig. 4,
both the scaled cumulant generating and the rate function are convex functions
and the latter has a unique minimum equal to zero.

Our thermodynamically consistent framework allows to translate the terminology
of nonlinear dynamics, _i.e._ the supercritical pitchfork bifurcation at the
critical temperature (113), into the language of nonequilibrium statistical
mechanics, _i.e._ a nonequilibrium phase transition at the same critical
temperature. For this purpose, we prepare the system in its critical state by
setting $\beta^{(h)}=1,\beta^{(c)}=3,u=-1$. Fig. 5 depicts in a) the scaled
cumulant generating function (118) with the system being in its critical
state. The scaled cumulant generating function exhibits a kink at
$\gamma^{(c)}_{{}_{\mathcal{E}}}=0$ indicative of a nonequilibrium phase
transition. Owing to the symmetry (119), the scaled cumulant generating
function has another kink at $\gamma^{(c)}_{{}_{\mathcal{E}}}=1$. The non-
differentiability of the generating function at
$\gamma^{(c)}_{{}_{\mathcal{E}}}=0$ implies that the rate function in Fig. 5
b) would be nonconvex over a finite interval. The Legendre-Fenchel
transformation (122) yields not the nononvex rate function but its convex
envelope $\Phi^{ce}\big{(}\delta\mathcal{J}^{(c),s}_{\mathcal{E}}\big{)}$.
Here, the part of the convex envelope that replaces the nonconvex regime of
the rate function corresponds to the flat part of the curve in the vicinity of
the $\delta\mathcal{J}^{(c),s}_{\mathcal{E}}=0$. Thus, we find that the time-
integrated energy current distribution in Eq. (121) is bimodal, thus also
encoding the nonequilibrium phase transition.

Figure 5: The cumulant generating function (118) scaled with time $t$ and size
$N$ in a) as a function of the counting field
$\gamma^{(c)}_{{}_{\mathcal{E}}}$ and the corresponding convex envelope of the
rate function $\Phi^{ce}\big{(}\delta\mathcal{J}^{(c),s}_{\mathcal{E}}\big{)}$
in b). The parameters are chosen as $\beta^{(h)}=1,\beta^{(c)}=3,u=-1$ where
the unbiased dynamics exhibits a phase transition (113).

##  VI Conclusion

In this work we demonstrated how to consistently build a stochastic dynamics
and thermodynamics description across scales for many-body systems with all-
to-all interactions: For this purpose, we considered a system of $N$ all-to-
all interacting identical and classical units consisting of $q$ states. The
units undergo transitions due to several heat reservoirs and because of
external forces. The _microscopic_ stochastic dynamics characterized by many-
body states can be exactly coarse-grained towards a _mesoscopic_ one that is
determined by the occupation numbers of the different unit states. Here, the
all-to-all interactions give rise to equienergetic many-body states which form
the mesostates. Importantly, the coarse-graining significantly reduces the
complexity of the many-body system as the growth of the state space changes
from an exponential to a power-law one. Employing the formalism of stochastic
thermodynamics, it was proven that the stochastic first law of thermodynamics
is always invariant under the dynamically exact coarse-graining. Conversely,
this only holds true for the stochastic entropy balance if the microstates
within each mesostate are equiprobable.

We then considered the macroscopic limit, $N\to\infty$. To consistently
determine the macroscopic fluctuations we used the Martin-Siggia-Rose
formalism. We showed that the fluctuations that scale exponentially with the
system size $N$ are thermodynamically consistent as they obey a detailed
fluctuation theorem. Detailed fluctuation theorems of the same form were also
derived at the microscopic and mesoscopic level, hence proving thermodynamic
consistency across scales. Moreover we proved via the path integral
representation of the stochastic dynamics that the mesoscopic master equation
asymptotically converges to a nonlinear rate equation. The methodology to
determine macroscopic fluctuations was demonstrated via a semi-analytically
solvable Ising model in contact with two reservoirs and exhibiting a
nonequilibrium phase transition. Our work provides a powerful framework to
address the thermodynamics of non-equilibrium phase transitions.

An interesting outcome of this work is that the thermodynamic description of
many-body all-to-all interacting systems, when going from a microscopic to an
occupation level description, assigns Boltzmann entropies (logarithms of
complexion numbers) to each mesostate, despite the fact that the system is
driven away from-equilibriun by multiple reservoirs and external forces.
Furthermore, in the deterministic macroscopic limit, $N\to\infty$, the ensuing
entropy takes the form of a Shannon entropy for the deterministic occupation
which exclusively results from these internal mesostate entropies.

Table 1 provides an overview of the dynamics, fluctuations, local detailed
balance (LDB), entropy, entropy production (EP) and detailed fluctuation
theorems (DFT) at the microscopic, mesoscopic and macroscopic level.

| Dynamics | Fluctuations | LDB | Entropy | EP | DFT
---|---|---|---|---|---|---
Microscopic | (3) | (46) | (5) | (80) | (81) | (68)
Mesoscopic | (14) | (58) | (17) | (80) | (81) | (74)
Macroscopic | (101) | (93),(96) | (91) | (107) | (108) | (99)
Table 1: Compilation of the key equations specifying the dynamics,
fluctuations, local detailed balance (LDB), entropy, entropy production (EP)
and detailed fluctuation theorems (DFT) at the microscopic, mesoscopic and
macroscopic level.

We end by placing our findings in the context of the recent works on
thermodynamically consistent coarse-graining. Many of these are based on time-
scale separation: fast degrees of freedom reach a local stationary state over
time-scales much shorter than the slow dynamics and can be adiabatically
eliminated. The resulting transition rates of the slow dynamics then satisfy a
local detailed balance condition which carries the information about the
thermodynamic potentials (energetic and/or entropic) Esposito (2012); Bo and
Celani (2014); Herpich  _et al._ (2020) or the driving forces Wachtel  _et
al._ (2018); Murashita and Esposito (2016); Esposito and Parrondo (2015)
resulting from the fast dynamics. Some coarse-grainings do not require time-
scale separation and the hidden degrees of freedom have been shown to behave
as work sources (pure energy no entropy) on the remaining degrees of freedom,
see e.g. Refs. Herpich  _et al._ (2020); Verley  _et al._ (2014b). In the
present work, the coarse-graining does not rely on any time-scale separation
but results from the all-to-all interactions which do not discriminate
energetically between the different microstates leading to the same global
occupation. As a result a purely entropic contributions ensues at the
occupation level. Models where such coarse grainings appeared can be found in
Refs. Herpich  _et al._ (2018); Herpich and Esposito (2019); Vroylandt  _et
al._ (2017).

## Acknowledgments

T. H. warmly thanks Gatien Verley for stimulating exchanges. We acknowledge
support by the National Research Fund, Luxembourg, in the frame of the AFR PhD
Grant 2016, No. 11271777 and by the European Research Council project
NanoThermo (ERC-2015-CoG Agreement No. 681456).

##  Appendix A Derivation of the Equiprobability of Microstates Inside
Stationary Mesostates

For finite systems, the stationary microscopic probabilities can be determined
via the spanning-tree formula Schnakenberg (1976). A spanning tree,
$\mathcal{T}(G)$ of a graph $G$ consists only of edges that are also edges of
$G$ and contains all vertices (microstates $\alpha$) of $G$. Further, a
spanning tree $\mathcal{T}^{\prime}(G)$ is connected and contains no circuits.
We write $\mathcal{T}^{(\mu)}_{\alpha}(G)$ for the $\mu$th spanning tree
rooted in $\alpha$, that is a tree with branches that are directed towards the
vertex $\alpha$. The spanning-tree formula reads

$\displaystyle
p^{s}_{\alpha}(\bm{\lambda})=\frac{\sum\limits_{\mu}\mathcal{T}^{(\mu)}_{\alpha}(G)}{\sum\limits_{\alpha}\sum\limits_{\mu}\mathcal{T}^{(\mu)}_{\alpha}(G)}=\frac{\sum\limits_{\mathcal{T}_{\alpha}(G)}\;\prod\limits_{\begin{subarray}{c}\alpha^{\prime},\alpha^{\prime\prime}\text{
such that }\\\ \text{ current is directed to
}\alpha\end{subarray}}w_{\alpha^{\prime}\alpha^{\prime\prime}}(\bm{\lambda})}{\sum\limits_{\alpha}\sum\limits_{\mathcal{T}_{\alpha}(G)}\prod\limits_{\begin{subarray}{c}\alpha^{\prime},\alpha^{\prime\prime}\text{
such that }\\\ \text{ current is directed to
}\alpha\end{subarray}}w_{\alpha^{\prime}\alpha^{\prime\prime}}(\bm{\lambda})}\,.$
(123)

First we note that the transition rates do not depend on the microstates
$\alpha$ and $\alpha^{\prime}$ belonging to the same pair of mesostates
$(\bm{N},\bm{N}^{\prime})$, _i.e._
$w_{\alpha_{{}_{\bm{N}}}\alpha^{\prime}_{{}_{\bm{N}^{\prime}}}}(\bm{\lambda})=\text{const
}\;\forall\,\alpha_{{}_{\bm{N}}},\alpha^{\prime}_{{}_{\bm{N}^{\prime}}}$.
Secondly, the number of possible transitions for any microstate belonging to a
given mesostate is a constant such that the number of spanning trees rooted in
$\alpha_{{}_{\bm{N}}}$ is constant for all $\alpha_{{}_{\bm{N}}}$. It
therefore holds that all microstates belonging to the same mesostate are
equally probable,

$\displaystyle p^{s}_{\alpha_{{}_{\bm{N}}}}(\bm{\lambda})$
$\displaystyle=\frac{\sum\limits_{\mathcal{T}_{\alpha_{\bm{N}}}(G)}\;\prod\limits_{\begin{subarray}{c}\alpha^{\prime}_{\bm{N}^{\prime}},\alpha^{\prime\prime}_{\bm{N}^{\prime\prime}}\text{
such that }\\\ \text{ current is directed to
}\alpha_{{}_{\bm{N}}}\end{subarray}}w_{\alpha^{\prime}_{\bm{N}^{\prime}},\alpha^{\prime\prime}_{\bm{N}^{\prime\prime}}}(\bm{\lambda})}{\sum\limits_{\bm{N}}\sum\limits_{\alpha_{{}_{\bm{N}}}}\sum\limits_{\mathcal{T}_{\alpha_{\bm{N}}}(G)}\;\prod\limits_{\begin{subarray}{c}\alpha^{\prime}_{\bm{N}^{\prime}},\alpha^{\prime\prime}_{\bm{N}^{\prime\prime}}\text{
such that }\\\ \text{ current is directed to
}\alpha_{{}_{\bm{N}}}\end{subarray}}w_{\alpha^{\prime}_{\bm{N}^{\prime}},\alpha^{\prime\prime}_{\bm{N}^{\prime\prime}}}(\bm{\lambda})}=\mathrm{const}\;\,\forall\,\alpha_{{}_{\bm{N}}},$
(124)

as claimed in Eq. (25).

##  Appendix B Derivation of the Detailed Fluctuation Theorem: Time-Evolution
Operator

In this section we prove the detailed fluctuation theorem (68) following a
procedure detailed in Ref. Rao and Esposito (2018b). We denote by
$p_{\alpha}\big{(}\delta w_{\bm{\lambda}},\\{\delta
j^{(\nu)}_{\bm{f}}\\},\\{\delta j^{(\nu)}_{e}\\},t\big{)}$ the joint
probability to observe a work contribution $\beta^{(1)}\delta
w_{\bm{\lambda}}$ defined in Eq. (32) and time-integrated autonomous work and
energy currents $\\{\delta j^{(\nu)}_{\bm{f}}\\}$ and $\\{\delta
j^{(\nu)}_{e}\\}$ defined in Eqs. (41) and (39), respectively, along a
trajectory that is in state $\alpha$ at time $t$. In the following, we note
arrays with bold characters whose entries in case of the generating function
$\bm{g}$ and the associated probability $\bm{p}$ correspond to different
microstates $\alpha$. According to Eqs. (42) and (44), the microscopic
generating function associated with $\delta w_{\bm{\lambda}}$, $\\{\delta
j^{(\nu)}_{\bm{f}}\\}$ and $\\{\delta j^{(\nu)}_{e}\\}$ is given by

$\displaystyle\begin{aligned}
\bm{g}(\mathrm{i}\gamma_{{}_{\bm{\lambda}}},\\{\mathrm{i}\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\mathrm{i}\gamma_{{}_{e}}^{(\nu)}\\},t)&=\int\limits_{-\infty}^{\infty}\prod_{\nu}\mathrm{d}\Big{(}\beta^{(1)}\delta
w_{\bm{\lambda}}\Big{)}\mathrm{d}\Big{(}\delta
j^{(\nu)}_{\bm{f}}\Big{)}\mathrm{d}\Big{(}\delta
j^{(\nu)}_{e}\Big{)}\;\cdot\\\
&\cdot\exp\Big{\\{}-\mathrm{i}\gamma_{{}_{\bm{\lambda}}}\beta^{(1)}\delta
w_{\bm{\lambda}}-\mathrm{i}\gamma_{{}_{\bm{f}}}^{(\nu)}\;\delta
j^{(\nu)}_{\bm{f}}-\mathrm{i}\gamma_{{}_{e}}^{(\nu)}\;\delta
j^{(\nu)}_{e}\Big{\\}}\,\bm{p}\big{(}\delta w_{\bm{\lambda}},\\{\delta
j^{(\nu)}_{\bm{f}}\\},\\{\delta j^{(\nu)}_{e}\\},t\big{)},\end{aligned}$ (125)

and its time evolution is governed by the following biased stochastic dynamics

$\displaystyle\mathrm{d}_{t}\,\bm{g}(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},t)$
$\displaystyle=\bm{w}(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},\bm{\lambda}_{t})\cdot\bm{g}(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},t),$
(126)

with the biased generator

$\displaystyle
w_{\alpha\alpha^{\prime}}(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},\bm{\lambda}_{t})=-\gamma_{{}_{\bm{\lambda}}}\,\beta^{(1)}\big{[}\dot{\bm{\lambda}}_{t}\cdot\nabla_{\bm{\lambda}_{t}}\,e_{\alpha}(\bm{\lambda}_{t})\big{]}\delta_{\alpha,\alpha^{\prime}}+w_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})\prod\limits_{\nu}\exp\Big{[}-\gamma_{j^{(\nu)}_{\bm{f}}}\;j^{(\nu)}_{{}_{\bm{f}_{\alpha\alpha^{\prime}}}}-\,\gamma_{j^{(\nu)}_{e}}\;j^{(\nu)}_{{}_{\alpha\alpha^{\prime}}}\Big{]},$
(127)

where
$j^{(\nu)}_{{}_{\bm{f}_{\alpha\alpha^{\prime}}}}=\beta^{(\nu)}\bm{f}^{(\nu)}_{\alpha,\alpha^{\prime}}$
and
$j^{(\nu)}_{e_{\alpha\alpha^{\prime}}}=[\beta^{(1)}-\beta^{(\nu)}][e_{\alpha}(\bm{\lambda}_{t})-e_{\alpha^{\prime}}(\bm{\lambda}_{t})]$
denote the change in the autonomous work and energy current during a
transition $\alpha^{\prime}\overset{(\nu)}{\to}\alpha$, respectively. We
easily verify with Eq. (5) that the biased generator satisfies the following
symmetry

$\displaystyle\bm{w}^{\top}(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},\bm{\lambda}_{t})=\bm{A}^{-1}(\bm{\lambda}_{t})\cdot\bm{w}(\gamma_{{}_{\bm{\lambda}}},\\{1-\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{1-\gamma_{{}_{e}}^{(\nu)}\\},\bm{\lambda}_{t})\cdot\bm{A}(\bm{\lambda}_{t}),$
(128)

with the matrix

$\displaystyle
A_{\alpha\alpha^{\prime}}(\bm{\lambda}_{t})=\exp\Big{[}-\beta^{(1)}e_{\alpha}(\bm{\lambda}_{t})\Big{]}\,\delta_{\alpha\alpha^{\prime}}.$
(129)

In this notation, the initial Gibbs states (65) can be written as

$\displaystyle\bm{g}(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},0)=\mathbf{p}^{eq}(\bm{\lambda}_{0})=\bm{A}(\bm{\lambda}_{0})\cdot\bm{1}\,\exp\Big{[}\beta^{(1)}a^{eq}_{1}(\bm{\lambda}_{0})\Big{]},$
(130)

where $\bm{1}$ refers to a vector whose entries are all unity.

Since it will be useful to proceed later, we now prove a preliminary result.
To this end, we consider a generic biased dynamics as in Eq. (126)

$\displaystyle\partial_{t}\,\bm{g}(\gamma,t)$
$\displaystyle=\bm{w}(\gamma,\bm{\lambda}_{t})\cdot\bm{g}(\gamma,t),$ (131)

which has the formal solution

$\displaystyle\bm{g}(\gamma,t)$
$\displaystyle=\bm{U}(\gamma,t)\cdot\bm{p}(0),$ (132)

with the time-evolution operator

$\displaystyle\bm{U}(\gamma,t)=T_{+}\;\exp\Bigg{[}\int\limits_{0}^{t}\mathrm{d}t^{\prime}\,\bm{w}(\gamma,\bm{\lambda}_{t^{\prime}})\Bigg{]},$
(133)

where $T_{+}$ is the time-ordering operator. We define a transformed time-
evolution operator

$\displaystyle\hat{\bm{U}}(\gamma,t)=\bm{B}^{-1}(\bm{\lambda}_{t})\cdot\bm{U}(\gamma,t)\cdot\bm{B}(\bm{\lambda}_{0})$
(134)

with a generic but invertible operator $\bm{B}$ and find for its evolution
equation

$\displaystyle\partial_{t}\hat{\bm{U}}(\gamma,t)=\big{\\{}[\mathrm{d}_{t}\bm{B}^{-1}(\bm{\lambda}_{t})]\cdot\bm{B}(\bm{\lambda}_{t})+\bm{B}^{-1}(\bm{\lambda}_{t})\cdot\bm{w}(\gamma,\bm{\lambda}_{t})\cdot\bm{B}(\bm{\lambda}_{t})\big{\\}}\,\hat{\bm{U}}(\gamma,t)\equiv\hat{\bm{w}}(\gamma,\bm{\lambda}_{t})\cdot\hat{\bm{U}}(\gamma,t),$
(135)

which implies for the transformed time-evolution operator

$\displaystyle\hat{\bm{U}}(\gamma,t)=T_{+}\;\exp\Bigg{[}\int\limits_{0}^{t}\mathrm{d}t^{\prime}\,\hat{\bm{w}}(\gamma,\bm{\lambda}_{t^{\prime}})\Bigg{]}.$
(136)

Combining the last three equations, we arrive at the preliminary result

$\displaystyle\bm{B}^{-1}(\bm{\lambda}_{t})\cdot\bm{U}(\gamma,t)\cdot\bm{B}(\bm{\lambda}_{0})=T_{+}\;\exp\Bigg{[}\int\limits_{0}^{t}\mathrm{d}t^{\prime}\,\Big{\\{}[\mathrm{d}_{t^{\prime}}\bm{B}^{-1}(\bm{\lambda}_{t^{\prime}})]\cdot\bm{B}(\bm{\lambda}_{t^{\prime}})+\bm{B}^{-1}(\bm{\lambda}_{t^{\prime}})\cdot\bm{w}(\gamma,\bm{\lambda}_{t^{\prime}})\cdot\bm{B}(\bm{\lambda}_{t^{\prime}})\Big{\\}}\Bigg{]}.$
(137)

We now return to the specific biased stochastic dynamics considered in Eq.
(126) and obtain for the generating function

$\displaystyle\begin{aligned}
g(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},t)&=\bm{1}\cdot\bm{U}(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},t)\cdot\bm{A}(\bm{\lambda}_{0})\cdot\bm{1}\,\exp\Big{[}\beta^{(1)}a^{eq}_{1}(\bm{\lambda}_{0})\Big{]}\\\
&=\\!\exp\\!\Big{[}\beta^{(1)}a^{eq}_{1}(\bm{\lambda}_{t})\big{]}\bm{1}\\!\cdot\\!\bm{A}(\bm{\lambda}_{t})\\!\cdot\\!\bm{A}^{-1}(\bm{\lambda}_{t})\\!\cdot\\!\bm{U}(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},t)\\!\cdot\\!\bm{A}(\bm{\lambda}_{0})\cdot\\!\bm{1}\\!\,\exp\Big{[}\\!-\\!\beta^{(1)}\Delta
a^{eq}_{1}(\bm{\lambda})\Big{]},\end{aligned}$ (138)

where
$\bm{U}(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},t)$
is the time-evolution operator for that biased stochastic dynamics. Owing to
the assumption of initial equilibrium distributions for the forward and
backward process, $p^{eq}(\bm{\lambda}_{0})$ and $p^{eq}(\bm{\lambda}_{t})$,
we have

$\displaystyle\mathbf{p}^{eq}(\bm{\lambda}_{t})=\bm{1}\cdot\bm{A}(\bm{\lambda}_{t})\,\exp\Big{[}\beta^{(1)}a^{eq}_{1}(\bm{\lambda}_{t})\Big{]}.$
(139)

Substituting the last and Eq. (137) into Eq. (138) gives

$\displaystyle\begin{aligned}
&g(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},t)\,=\\\
&=\\!\\!\mathbf{p}^{eq}(\bm{\lambda}_{t})\\!\cdot\\!T_{+}\\!\exp\\!\Bigg{[}\\!\int\limits_{0}^{t}\\!\mathrm{d}t^{\prime}\\!\big{\\{}[\dot{\bm{\lambda}}_{t^{\prime}}\\!\cdot\\!\\!\nabla_{\bm{\lambda}_{t^{\prime}}}\bm{A}^{-1}(\bm{\lambda}_{t^{\prime}})]\\!\cdot\\!\\!\bm{A}(\bm{\lambda}_{t^{\prime}})\\!\\!+\\!\\!\bm{A}^{-1}(\bm{\lambda}_{t^{\prime}})\\!\cdot\\!\bm{w}(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},\bm{\lambda}_{t^{\prime}})\\!\cdot\\!\bm{A}(\bm{\lambda}_{t^{\prime}})\big{\\}}\\!\Bigg{]}\\!\\!\cdot\\!\bm{1}\exp\\!\\!\big{[}\\!-\\!\beta^{(1)}\Delta
a^{eq}_{1}(\bm{\lambda})\big{]}\\\ &=\mathbf{p}^{eq}(\bm{\lambda}_{t})\cdot
T_{+}\;\exp\Bigg{[}\int\limits_{0}^{t}\mathrm{d}t^{\prime}\,\bm{A}^{-1}(\bm{\lambda}_{t^{\prime}})\cdot\bm{w}(\gamma_{{}_{\bm{\lambda}}}-1,\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},\bm{\lambda}_{t^{\prime}})\cdot\bm{A}(\bm{\lambda}_{t^{\prime}})\Bigg{]}\cdot\bm{1}\;\exp\big{[}-\beta^{(1)}\Delta
a^{eq}_{1}(\bm{\lambda})\big{]}\\\ &=\mathbf{p}^{eq}(\bm{\lambda}_{t})\cdot
T_{+}\;\exp\Bigg{[}\int\limits_{0}^{t}\mathrm{d}t^{\prime}\,\bm{w}^{\top}(\gamma_{{}_{\bm{\lambda}}}-1,\\{1-\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{1-\gamma_{{}_{e}}^{(\nu)}\\},\bm{\lambda}_{t^{\prime}})\Bigg{]}\cdot\bm{1}\;\exp\big{[}-\beta^{(1)}\Delta
a^{eq}_{1}(\bm{\lambda})\big{]},\end{aligned}$ (140)

where we used
$[\dot{\bm{\lambda}}_{t^{\prime}}\cdot\nabla_{\bm{\lambda}_{t^{\prime}}}\bm{A}^{-1}(\bm{\lambda}_{t^{\prime}})]\cdot\bm{A}(\bm{\lambda}_{t^{\prime}})=\beta^{(1)}\,\mathrm{diag}\\{\dot{\bm{\lambda}}_{t^{\prime}}\cdot\nabla_{\bm{\lambda}_{t^{\prime}}}E_{\bm{N}}(\bm{\lambda}_{t})\\}$
in the second and Eq. (128) in the last equality. Next, we transform the time
from $t^{\prime}$ to $\tilde{t^{\prime}}=t-t^{\prime}$ corresponding to a
time-reserved process. As a result of this transformation, the time-ordering
operator becomes an anti-time-ordering one $T_{-}$ and the diagonal entries of
the biased generator (127) become

$\displaystyle
w_{\alpha\alpha}(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},\bm{\lambda}_{t-\tilde{t^{\prime}}})=\gamma_{{}_{\bm{\lambda}}}\,\dot{\bm{\lambda}}_{t-\tilde{t^{\prime}}}\cdot\nabla_{\bm{\lambda}_{t-\tilde{t^{\prime}}}}\,e_{\alpha}(\bm{\lambda}_{t-\tilde{t^{\prime}}})+w_{\alpha\alpha}(\bm{\lambda}_{t-\tilde{t^{\prime}}})=-\gamma_{{}_{\bm{\lambda}}}\,\dot{\bm{\lambda}}_{t-\tilde{t^{\prime}}}\cdot\nabla_{\bm{\lambda}_{\tilde{t^{\prime}}}}\,e_{\alpha}(\bm{\lambda}_{t-\tilde{t^{\prime}}})+w_{\alpha\alpha}(\bm{\lambda}_{t-\tilde{t^{\prime}}}).$
(141)

Thus, we conclude that

$\displaystyle
w_{\alpha\alpha^{\prime}}(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},\bm{\lambda}_{t-\tilde{t^{\prime}}})=w_{\alpha\alpha^{\prime}}(-\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},\bm{\lambda}_{t-\tilde{t^{\prime}}})\equiv\tilde{w}_{\alpha\alpha^{\prime}}(-\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},\tilde{\bm{\lambda}}_{\tilde{t}^{\prime}}),$
(142)

where we introduced the biased generator of the time-reversed stochastic
dynamics
$\tilde{w}_{\alpha\alpha^{\prime}}(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},\tilde{\bm{\lambda}}_{t^{\prime}})$
that is naturally a function of the time-reversed protocol,
$\tilde{\bm{\lambda}}_{t^{\prime}}=\bm{\lambda}_{t-t^{\prime}},\,t^{\prime}\leavevmode\nobreak\
\in\leavevmode\nobreak\ [0,t]$. Consequently, Eq. (140) becomes

$\displaystyle\begin{aligned}
g(\gamma_{w_{\tilde{\bm{\lambda}}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},t)&=\tilde{\mathbf{p}}^{eq}(\tilde{\bm{\lambda}}_{0})\cdot
T_{-}\;\exp\Bigg{[}\int\limits_{0}^{t}\mathrm{d}\tilde{t^{\prime}}\,\tilde{\bm{w}}^{\top}(1-\gamma_{{}_{\bm{\lambda}}},\\{1-\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{1-\gamma_{{}_{e}}^{(\nu)}\\},\tilde{\bm{\lambda}}_{t^{\prime}})\Bigg{]}\cdot\bm{1}\;\exp\big{[}-\beta^{(1)}\Delta
a^{eq}_{1}(\bm{\lambda})\big{]}\\\ &=\bm{1}\cdot
T_{+}\;\exp\Bigg{[}\int\limits_{0}^{t}\mathrm{d}\tilde{t^{\prime}}\,\tilde{\bm{w}}(1-\gamma_{{}_{\bm{\lambda}}},\\{1-\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{1-\gamma_{{}_{e}}^{(\nu)}\\},\tilde{\bm{\lambda}}_{t^{\prime}})\Bigg{]}\cdot\tilde{\mathbf{p}}^{eq}(\tilde{\bm{\lambda}}_{0})\;\exp\big{[}-\beta^{(1)}\Delta
a^{eq}_{1}(\bm{\lambda})\big{]}.\end{aligned}$ (143)

In the last equality we applied a global transposition and used the
relationship

$\displaystyle
T_{+}\Big{(}\prod\limits_{i}\bm{C}(\bm{\lambda}_{t_{i}})^{\top}\Big{)}=\Big{(}T_{-}\prod\limits_{i}\bm{C}(\bm{\lambda}_{t_{i}})\Big{)}^{\top},$
(144)

that is valid for a generic operator $\bm{C}$. Inserting Eq. (136) into Eq.
(143) yields

$\displaystyle\begin{aligned}
g(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},t)&=\bm{1}\cdot\tilde{\bm{U}}(1-\gamma_{{}_{\bm{\lambda}}},\\{1-\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{1-\gamma_{{}_{e}}^{(\nu)}\\},t)\cdot\tilde{\mathbf{p}}^{eq}(\tilde{\bm{\lambda}}_{t})\;\exp\big{[}-\beta^{(1)}\Delta
a^{eq}_{1}(\bm{\lambda})\big{]},\end{aligned}$ (145)

from which we conclude the following symmetry

$\displaystyle
g(\gamma_{{}_{\bm{\lambda}}},\\{\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{\gamma_{{}_{e}}^{(\nu)}\\},t)=\tilde{g}(1-\gamma_{{}_{\bm{\lambda}}},\\{1-\gamma_{{}_{\bm{f}}}^{(\nu)}\\},\\{1-\gamma_{{}_{e}}^{(\nu)}\\},t)\;\exp\big{[}-\beta^{(1)}\Delta
a^{eq}_{1}(\bm{\lambda})\big{]},$ (146)

which via inverse Fourier transformation of the definition (125) stipulates
the detailed fluctuation theorem

$\displaystyle\ln\frac{p\Big{(}\beta^{(1)}\delta w_{\bm{\lambda}},\\{\delta
j^{(\nu)}_{\bm{f}}\\},\\{\delta
j^{(\nu)}_{e}\\}\Big{)}}{\tilde{p}\Big{(}-\beta^{(1)}\delta
w_{\bm{\lambda}}\,,-\\{\delta j^{(\nu)}_{\bm{f}}\\},-\\{\delta
j^{(\nu)}_{e}\\}\Big{)}}=\beta^{(1)}\big{[}\delta w_{\bm{\lambda}}-\Delta
a^{eq}_{1}\big{]}+\sum\limits_{\nu=1}^{L}\big{[}\beta^{(\nu)}\delta
w_{\bm{f}}^{(\nu)}+\big{[}\beta^{(1)}-\beta^{(\nu)}\big{]}\delta
e^{(\nu)}\big{]},$ (147)

as stated in Eq. (68).

##  Appendix C Derivation of the Detailed Fluctuation Theorem: Path-Integral
Formalism

We finally present the proof of the asymptotic symmetry in Eq. (98). The path-
integral representation of the dominant contribution to the generating
function associated with the size-extensive fluctuations of the mesoscopic
entropy production with bounding Gibbs states (93) reads

$\displaystyle\begin{aligned}
&G(\bm{\gamma},t)=\int\mathcal{D}[\bm{\overline{n}}]\int\mathcal{D}[\bm{\pi}]\;P_{\bm{\overline{n}}_{{}_{0}}}^{eq}(\bm{\lambda}_{0})\cdot\exp\Bigg{\\{}N\int\limits_{0}^{t}\mathrm{d}t^{\prime}\Bigg{[}\\!-\\!\gamma_{{}_{\bm{\lambda}}}\beta^{(1)}\dot{\bm{\lambda}}_{t^{\prime}}\cdot\big{[}\nabla_{\bm{\lambda}_{t^{\prime}}}\mathcal{E}_{\bm{\overline{n}}}(\bm{\lambda}_{t^{\prime}})\big{]}+\sum\limits_{i=1}^{q}\Big{\\{}-\pi_{i}(t^{\prime})\dot{\overline{n}}_{i}(t^{\prime})\\\
&+\\!\sum\limits_{\nu=1}^{L}\sum\limits_{j=1}^{q}\\!\Big{[}\\!\exp\Big{\\{}\pi_{i}(t^{\prime})\\!-\\!\pi_{j}(t^{\prime})\\!-\\!\gamma_{{}_{\bm{f}}}^{(\nu)}\beta^{(\nu)}f_{ij}^{(\nu)}\\!-\\!\gamma_{\mathcal{E}}^{(\nu)}[\beta^{(1)}\\!-\\!\beta^{(\nu)}]\,\mathcal{E}_{ij}^{(\nu)}\big{(}\bm{\lambda}_{t^{\prime}},\bm{\overline{n}}(t^{\prime})\big{)}\\!\Big{\\}}\\!-\\!1\Big{]}k_{ij}^{(\nu)}\big{(}\bm{\lambda}_{t^{\prime}},\bm{\overline{n}}(t^{\prime})\big{)}\,\overline{n}_{j}(t^{\prime})\Big{\\}}\Bigg{]}\Bigg{\\}},\end{aligned}$
(148)

where, for better readability, the subextensive terms in the exponential,
$\mathbbm{o}(1)$, are omitted in the following.

The crucial step of the derivation is to define physically consistent
transformation rules to time-reverse the biased stochastic dynamics. Time-
reversal transformations of unbiased Langevin dynamics have been investigated
in Ref. Aron  _et al._ (2010). For the generating function in question (148),
we define the time-reversed biased stochastic dynamics as follows

$\displaystyle\begin{aligned}
&\tilde{t}^{\prime}=t-t^{\prime},\quad\tilde{\bm{\overline{n}}}=\bm{\overline{n}},\quad\tilde{\bm{\lambda}}_{t^{\prime}}=\bm{\lambda}_{t-t^{\prime}},\\\
&\tilde{\bm{\pi}}=-\bm{\pi}+\beta^{(1)}\,\nabla_{\bm{\overline{n}}}\,\mathcal{A}_{\bm{\overline{n}}}^{(\nu)}(\bm{\lambda}_{t})=-\bm{\pi}+\beta^{(1)}\,\nabla_{\bm{\overline{n}}}\,\mathcal{E}_{\bm{\overline{n}}}(\bm{\lambda}_{t})-\nabla_{\bm{\overline{n}}}\,\mathcal{S}^{int}_{\bm{\overline{n}}},\quad\tilde{\bm{\gamma}}=1-\bm{\gamma},\end{aligned}$
(149)

while reusing the shorthand notation from Eq. (73). The definitions of the
time-reversed physical quantities in the first line are trivial. Less obvious
is the transformation rule of the auxiliary field $\bm{\pi}$. This
transformation rule amounts to inverting the directions of the edges
corresponding to a reversion of the Markov dynamics: The change of the sign in
front of $\bm{\pi}$ can be seen by noting that the latter is a counting field
for variations in the state variables $\mathrm{d}\bm{\overline{n}}$. Moreover,
the affinity along an edge is inverted by the free energy shift.

We proceed by demonstrating that the above transformation, up to a non-
fluctuating quantity, indeed leaves the generating function invariant. For
better readability, we will split the action functional (148) into two parts
and investigate how they transform under the time reversal in Eq. (149).
First, the invariance of the biased Hamiltonian under this time-reversal
transformation can be seen as follows,

$\displaystyle\begin{aligned}
&\tilde{H}_{\tilde{\bm{\gamma}}}[\bm{\overline{n}}(t^{\prime}),\bm{\pi}(t^{\prime})]=\\\
&=\sum\limits_{\nu=1}^{L}\sum\limits_{i,j=1}^{q}\Big{[}\exp\Big{\\{}\pi_{j}(t^{\prime})-\pi_{i}(t^{\prime})+\beta^{(1)}(\partial_{\overline{n}_{i}}-\partial_{\overline{n}_{j}})\mathcal{A}_{\bm{\overline{n}}}^{(1)}(\bm{\lambda}_{t}^{\prime})+\big{(}\gamma_{{}_{\bm{f}}}^{(\nu)}-1\big{)}\beta^{(\nu)}f_{ij}^{(\nu)}\;+\\\
&+\big{(}\gamma_{E}^{(\nu)}-1\big{)}[\beta^{(1)}-\beta^{(\nu)}](\partial_{\overline{n}_{i}}-\partial_{\overline{n}_{j}})\mathcal{E}_{\bm{\overline{n}}}^{(1)}(\bm{\lambda}_{t}^{\prime})\Big{\\}}-1\Big{]}k_{ij}^{(\nu)}(\bm{\lambda}_{t^{\prime}},\bm{\overline{n}}(t^{\prime}))\,\overline{n}_{j}(t^{\prime})\\\
&=\sum\limits_{\nu=1}^{L}\sum\limits_{i,j=1}^{q}\Big{[}\exp\Big{\\{}\pi_{j}(t^{\prime})-\pi_{i}(t^{\prime})-\beta^{(1)}(\partial_{\overline{n}_{j}}-\partial_{\overline{n}_{i}})\mathcal{A}_{\bm{\overline{n}}}^{(1)}(\bm{\lambda}_{t}^{\prime})+\big{(}1-\gamma_{{}_{\bm{f}}}^{(\nu)}\big{)}\beta^{(\nu)}f_{ji}^{(\nu)}\;+\\\
&+\big{(}1-\gamma_{E}^{(\nu)}\big{)}[\beta^{(1)}-\beta^{(\nu)}](\partial_{\overline{n}_{j}}-\partial_{\overline{n}_{i}})\mathcal{E}_{\bm{\overline{n}}}^{(\nu)}(\bm{\lambda}_{t}^{\prime})\Big{\\}}-1\Big{]}k_{ij}^{(\nu)}(\bm{\lambda}_{t^{\prime}},\bm{\overline{n}}(t^{\prime}))\,\overline{n}_{j}(t^{\prime})\\\
&=\sum\limits_{\nu=1}^{L}\sum\limits_{i,j=1}^{q}\Big{[}\exp\Big{\\{}\pi_{j}(t^{\prime})-\pi_{i}(t^{\prime})-\beta^{(\nu)}\big{[}(\partial_{\overline{n}_{j}}-\partial_{\overline{n}_{i}})\mathcal{A}_{\bm{\overline{n}}}^{(\nu)}(\bm{\lambda}_{t}^{\prime})-f_{ji}^{(\nu)}\big{]}-\gamma_{{}_{\bm{f}}}^{(\nu)}\beta^{(\nu)}f_{ji}^{(\nu)}\;-\\\
&-\gamma_{E}^{(\nu)}[\beta^{(1)}-\beta^{(\nu)}](\partial_{\overline{n}_{j}}-\partial_{\overline{n}_{i}})\mathcal{E}_{\bm{\overline{n}}}^{(\nu)}(\bm{\lambda}_{t}^{\prime})\Big{\\}}-1\Big{]}k_{ij}^{(\nu)}(\bm{\lambda}_{t^{\prime}},\bm{\overline{n}}(t^{\prime}))\,\overline{n}_{j}(t^{\prime})\\\
&=\sum\limits_{\nu=1}^{L}\sum\limits_{i,j=1}^{q}\Big{[}\exp\big{[}\pi_{j}(t^{\prime})-\pi_{i}(t^{\prime})\big{]}\,\frac{k_{ji}^{(\nu)}(\bm{\lambda}_{t^{\prime}},\bm{\overline{n}}(t^{\prime}))\,\overline{n}_{i}(t^{\prime})}{k_{ij}^{(\nu)}(\bm{\lambda}_{t^{\prime}},\bm{\overline{n}}(t^{\prime}))\,\overline{n}_{j}(t^{\prime})}\,\cdot\\\
&\cdot\exp\Big{\\{}-\gamma_{{}_{\bm{f}}}^{(\nu)}\beta^{(\nu)}f_{ji}^{(\nu)}-\gamma_{E}^{(\nu)}[\beta^{(1)}-\beta^{(\nu)}](\partial_{\overline{n}_{j}}-\partial_{\overline{n}_{i}})\mathcal{E}_{\bm{\overline{n}}}^{(\nu)}(\bm{\lambda}_{t}^{\prime})\Big{\\}}-1\Big{]}k_{ij}^{(\nu)}(\bm{\lambda}_{t^{\prime}},\bm{\overline{n}}(t^{\prime}))\,\overline{n}_{j}(t^{\prime})\\\
&=\sum\limits_{\nu=1}^{L}\sum\limits_{i,j=1}^{q}\Big{[}\exp\Big{\\{}\pi_{j}(t^{\prime})-\pi_{i}(t^{\prime})-\gamma_{{}_{\bm{f}}}^{(\nu)}\beta^{(\nu)}f_{ji}^{(\nu)}-\gamma_{E}^{(\nu)}[\beta^{(1)}-\beta^{(\nu)}](\partial_{\overline{n}_{j}}-\partial_{\overline{n}_{i}})\mathcal{E}_{\bm{\overline{n}}}^{(\nu)}(\bm{\lambda}_{t}^{\prime})\Big{\\}}-1\Big{]}k_{ji}^{(\nu)}(\bm{\lambda}_{t^{\prime}},\bm{\overline{n}}(t^{\prime}))\,\overline{n}_{i}(t^{\prime})\\\
&=H_{\bm{\gamma}}[\bm{\overline{n}}(t^{\prime}),\bm{\pi}(t^{\prime})].\end{aligned}$
(150)

Furthermore, we find for the sum of the kinetic and non-autonomous driving
terms together with the initial condition under time-reversal,

$\displaystyle\int\limits_{0}^{t}\mathrm{d}t^{\prime}\,\Big{\\{}\big{[}\,\beta^{(1)}\,\nabla_{\bm{\overline{n}}}\,\mathcal{A}_{\bm{\overline{n}}}^{(1)}(\bm{\lambda}_{t}^{\prime})-\bm{\pi}(t^{\prime})\big{]}\cdot\dot{\bm{\overline{n}}}(t^{\prime})+(1-\gamma_{{}_{\bm{\lambda}}})\,\beta^{(1)}\dot{\bm{\lambda}}_{t^{\prime}}\cdot\left[\nabla_{\bm{\lambda}_{t^{\prime}}}\mathcal{E}_{\bm{\overline{n}}}(\bm{\lambda}_{t}^{\prime})\right]\Big{\\}}+\ln
P_{\bm{\overline{n}}_{t}}^{eq}(\bm{\lambda}_{t})\,=$ $\displaystyle=$