Second law of thermodynamics for batteries with vacuum state

We study the implications of introducing vacuum state of the battery for arbitrary thermodynamic processes. Using the framework of thermal operations we derive a form of the second law which holds for batteries with bounded energy spectrum. In this form the second law gains corrections which vanish when battery is initialized far from the bottom of its spectrum. Furthermore, by studying a paradigmatic example of Landauer erasure we show that the existence of battery ground state leads to a thermodynamic behaviour which cannot be realized using an ideal weight. Surprisingly, this remains true even when battery operates far from its bottom. Our results are formulated in the language of quantum mechanics, but they can be similarly applied to classical (stochastic) systems as well.


I. INTRODUCTION
Second law of thermodynamics sets limits for all physical processes. It determines which state transformations are possible, regardless of the microscopic details of the governing process. Most importantly, it imposes fundamental restrictions on the amount of work that can be performed by any physical process. For a system in contact with a thermal reservoir at inverse temperature β, the amount of average work w performed by the system evolving from ρ towards ρ is upper bounded by: where F (ρ) := tr [Hρ] -S(ρ)/β is the equilibrium free energy, H is the Hamiltonian of the system and S(ρ) := − s p(s) log p(s) for ρ = s p(s) |s s| is the ordinary von Neumann entropy. Second law of thermodynamics is a statistical law and as such, it governs how thermodynamic systems evolve on average. This information may be relevant for a macroscopic observer, however, in general it does not allow to infer anything about microscopic details of the occurring process. Recent developments in experimental techniques allow for manipulating and measuring systems at the nanoscale level [1][2][3][4][5][6]. In order to take full advantage of these techniques it is crucial to understand how thermodynamic laws translate in to the quantum domain, where fluctuations of thermodynamic quantities begin to play a significant role. For such systems it is no longer possible to properly specify their behaviour using only averaged quantities. This motivates extending thermodynamic framework to systems driven out of equilibrium, a setting which has been extensively studied using the so-called fluctuation theorems [7][8][9][10][11][12][13].
Recently, Alhambra et. al in [9] using the framework of thermal operations derived a quantum identity which relates fluctuations of work in thermodynamic processes.
They also showed that for quasi-classical states, that is the states block-diagonal in energy eigenbasis, this quantum identity reduces to the equality: where f i := E i + 1 β log p(i) and w are random variables, E i is the energy of i-th level the system and averaging is over p(s, s , w), that is the probability that system starts in state |s and ends up in state |s while performing work w. The above relation can be thought of as a generalization of the second law of thermodynamics (1), which results from applying Jensen's inequality to (2) . Moreover, when both initial and final states of the system are thermal (2), gives the ordinary Jarzynski equality [7,8].
However, the derivation of (2) relied on the fact that thermodynamic work is defined by shifts on an idealized battery: a doubly-infinite weight with unbounded Hamiltonian H W = ∞ −∞ d x |x x| W , where the basis {|x W , x ∈ R} is formed from continuous orthonormal states which represent position of the weight. The authors of [9] then assumed a global unitary dynamics acting on the combined state of the system, battery and heat bath which takes the system from ρ to ρ and acts independently of the initial position of the weight (a feature called translational invariance). This additional assumption makes it impossible to dump entropy into the battery [14] or, in other words, assures that drawing work from a single heat bath is forbidden. This is a common trait taken in many of the recent approaches to quantum thermodynamics [9,10,[14][15][16] which originated from [17]. However, even though this definition of work is often convenient computationally, it lacks real physical motivation. In particular, it can be argued that a doubly-infinite weight is not a realistic model of a battery as all physical systems have a ground state energy. It is widely believed that when transformation is performed sufficiently far from the vacuum, then a doubly-infinite A battery with unbounded spectrum (a), attached to the system and environment, works as a tool to define work by changes of its average energy w during operations described by unitaries applied to the system, battery and environment. For a given transition between system states, s → s , transitions between selected energy levels of the battery are represented by arrows (c), (d) -the width of an arrow is proportional to the probability value. A common assumption that the unitaries commute with the shift operator on the unbounded battery (a) leads to the conclusion that probabilities of transitions on the battery are the same for the same energy gain on the battery, disregarding what is its the initial state (c). For a physical model of a battery bounded from below, unitaries cannot commute with the shift operator, as presence of vacuum affects the initial distribution of battery populations (b). We model this by allowing transitions emerging from levels below min to break translational invariance (d). This introduces corrections to standard second law inequality for w , which shows that the average change of the energy of the battery ceases to serve as a good measure of work. While the corrections vanish exponentially with the distance between min and the bulk of pW ( ), the presence of vacuum affects the conditional work distribution, allowing for perfect Landauer erasure on physical batteries.
weight becomes equivalent to physical batteries [15,18] and reproduces the same qualitative results as any battery equipped with a vacuum state. However, the Nature we observe often does not follow this scheme. The existence of the ground state can be qualitatively perceived, no matter how far we are from it. A basic question then appears: does the existence of a vacuum state of the bat-tery has any implications for real thermodynamic processes?
There is also another, perhaps less fundamental but still important question. Namely, it was shown in [9] that for an approximate Landauer erasure (erasure with a small probability of failure ε), work necessarily fluctuates around some well-defined mean value. A similar behavior was noticed in [17] using a slightly different framework, but the same model of a battery. Crucially, these fluctuations grow indefinitely as the accuracy of erasure process increases. This is in stark contrast with previous results [19][20][21] obtained using a more physical battery modelled by a single qubit (called a work-bit, or in short: wit) with Hamiltonian H W = ∆ |1 1| W and energy spacing ∆ tuned to the desired transformation on the system. In that case perfect erasure was shown to be possible, and infinite fluctuations of work were not observed. This rises another general question: are the results obtained using wit legitimate and provide a valid description of single-shot thermodynamic processes?
In this paper we study thermodynamic processes involving batteries with bounded energy spectrum. This contrasts with the classical treatment of work in the sense that when battery operates close to its vacuum state it can no longer supply arbitrary values of work. In particular, only those values of work are allowed which do not reduce its energy below the ground state level. Surprisingly, it turns out that this small modification has far-reaching consequences for thermodynamic processes. We show that the possible work distributions are qualitatively different when battery does and does not have a vacuum state. This difference does not depend on how far from the vacuum the battery operates, i.e. it does not vanish for large energies of the battery. Using the example of Landauer erasure we explicitly show that for bounded batteries fluctuations of work in a deterministic process vanish when the battery is used above its ground state. Furthermore, we show that when vacuum state of the battery is explicitly included, the formulation of the second law of thermodynamics in terms of average work and free energy gains correction terms which strongly depend on how far from the vacuum the battery operates. As one might expect, these corrections do vanish exponentially fast with the distance to the vacuum. These violations indicate that when battery is initialized near the vacuum state, its average energy change can no longer describe a legitimate thermodynamic work. Finally, we show that our model correctly reproduces the single-shot results on work of formation and distillation originally derived using a qubit as a battery system [19].
The paper is organized as follows. We start by shortly presenting the framework of thermal operations. Then we present a refined form of the second law of thermodynamics valid for batteries with a bounded spectrum. We then describe a construction which extends (in a sense which will be made precise later) thermal operations defined for a qubit battery to thermal operations acting on a harmonic oscillator battery in a translationally-invariant manner. As an application of the construction, we compare the example of Landauer erasure using three different battery models (a wit (qubit), a doublyinfinite weight and a harmonic oscillator). We show that harmonic oscillator battery reproduces the perfect erasure limit in the single-shot scenario (erasure with arbitrary accuracy is possible with a bounded work cost) and thus, correctly reproduces known results obtained using a qubit battery. We finish the paper with a short discussion on the possible implications of these results and highlight the importance of including vacuum state of the battery in general thermodynamic protocols.

II. FRAMEWORK
Throughout the paper we will adapt a resourcetheoretic approach to quantum thermodynamics called thermal operations [14,[19][20][21][22][23][24][25][26][27][28][29][30][31][32][33][34][35]. This is a well established framework for studying thermodynamic processes in the quantum regime, involving systems in contact with infinite heat baths and represents the most that an experimenter can do when manipulating a system without access to external resources like coherence [15,[36][37][38][39], entanglement [40][41][42] or conserved quantities [43][44][45]. The setting consists of a system S with Hamiltonian H S that we would like to apply our transformations on, an infinite heat bath B with Hamiltonian H B , initially in a Gibbs state τ B = e −βH B /Z B , where Z B = tr e −βH B , and a battery system W with Hamiltonian H W . Unless otherwise specified, we will take the battery to be an (N + 1)-dimensional harmonic oscillator with Hamiltonian H W = N k=0 k | k k | W , where k = k · ∆ and ∆ is the energy separation between subsequent levels. Any joint transformation of system S and battery W in the presence of heat bath B can be represented by a quantum channel Γ SW : where ρ S = s p S (s) |s s| S , ρ W = k p W (k) | k k | W are initial states of the system and the battery. Operator U in (3) can be any unitary which commutes with the total Hamiltonian, that is [U, This can be thought of as a microscopic statement of the first law of thermodynamics. We will refer to any Γ SW of the above form as a thermal operation. Throughout this paper we will consider only incoherent states of the system, that is the states satisfying [H S , ρ S ] = 0. For such states thermal operations are equivalent to thermal processes [19,46,47], which are channels preserving the Gibbs state: Γ SW [τ SW ] = τ SW . We will use this realization extensively in the rest of the paper and carry out our proofs for this class of operations. We should emphasise that thermal processes (also known as Gibbs-preserving maps when considering arbitrary quantum states) are the most general class of thermodynamic operations which does not trivialize the theory [39,48] and as such, they highlight the boundary for any model of thermodynamic interactions. In other words, this class of operations gives the experimenter the most power when transforming states in the presence of a heat bath with a fixed background temperature. Any thermal process Γ SW can be fully characterized by a set of channel probabilities {r(s k |sk)} which describe the probability that state |s S ⊗ | k W is mapped to |s S ⊗ | k . They are related to the map Γ SW in the following way: Moreover, since Γ SW is a stochastic map which preserves the Gibbs state, channel probabilities additionally satisfy: We will now make an additional assumption about Γ SW which is necessary to interpret shifts on the battery W as a legitimate thermodynamic work. Let us assume that the channel is translationally invariant with respect to translations on the battery above a certain threshold energy min := ∆ · k min for some 0 ≤ k min ≤ N . This means that for all possible transitions, that is for all values of s, s and k, k such that k ≥ k min , we have: r(s k |sk) = r(s , k + n|s, k + n), for the values of n ∈ N such that 0 ≤ k + n ≤ N and k min ≤ k + n ≤ N . We will refer to the set of energy levels below and above min as the vacuum and invariant regime respectively. This additional assumption implies that whenever there is a non-zero probability of taking the battery from | k W to | k W , then all transitions related to the work cost w = k − k occur with the same probability. This is the analogue of the assumption about translational invariance on the weight, that is the commutation between global unitary U from (3) and a shift operator ∆ y := ∞ −∞ d x |x + y x| for all y. Notice that for a battery with a ground state the above operator is not properly defined for all y, and therefore a slightly more general notion of translational invariance is needed. In this sense (7) is the most general condition one can assume for bounded batteries, which in the same time reduces to commutation with shifts when battery is unbounded from both below and above. It is worth noting that taking the invariant regime of (7) with k min = 0 does not make much sense as there is only one thermal process which can satisfy it -the identity map.
Let us now move on to defining thermodynamic work in the framework. Before and after applying the global unitary U energy of the battery system is measured using projective measurements, obtaining outcomes | k W and | k + w W respectively. Work w is then a random variable with probability distribution given by: where Π k = | k k | W is a projector onto one of the energy eigenstates of W . Defining work in this way, along with imposing channel constraints (5), (6) and (7), allows to treat the random variable w as a candidate for work extracted from system S. Below we show that when the battery is initialized far away from the vacuum regime, w satisfies the ordinary inequality formulation of the second law of thermodynamics, justifying the choice.

A. Second law for real batteries
Let us now present our main result, that is the modified form of the second law of thermodynamics valid for batteries with bounded spectrum. For clarity of presentation we provided a fully rigorous proof in the Appendix and here we sketch the most relevant parts to support it. Theorem 1. Let Γ SW be a thermal process with channel probabilities {r(s k |sk)} acting on a harmonic oscillator battery W N and satisfying (7). Then, for any initial battery state where the correction terms are given by: = max s E s is the maximal energy of system S, F (ρ S ) is the free energy of the initial state ρ S and δ k := k − min + ∆.
Let us start by briefly studying the behaviour of terms on the RHS of (9). First, notice that the upper bound for average work w has two different correction terms which depend on the initial state of the battery. The first of them vanishes exactly when battery has no support on the energy eigenspace below the threshold energy min . The second term decreases exponentially fast with the distance to min and effectively vanishes when battery starts far away from it. In particular, if the battery operates sufficiently far from the threshold energy, that is k<k * p W (k) ≈ 0 for some k * k min , then both correction terms vanish and (9) reduces to the ordinary form of the second law.
To illustrate it more clearly, let us consider an infinitedimensional battery, N → ∞, with initial population p( < * ) below some energetic cut-off * above the vacuum regime: * > min . Then, the following holds: Corollary 1. For any thermal process acting on arbitrary system S and infinitely big battery with threshold energy min we have: with and constant c S := d S e βE max S depends only on system S.
For initial probability distribution on the battery concentrated far away from the vacuum, the term C( * , ρ W ) vanishes exponentially in the low energy regime (see Fig.  2).
We present the proof of the corollary in Appendix. Let us stress here that the possible violation of the second law inequality, which can occur when the battery is initialized in the proximity of the vacuum regime, is an indication that in such case the average change of the energy of the battery can no longer be considered as a valid physical quantity describing work.
Sketch of proof of Theorem 1. The standard approach to deriving second law in stochastic thermodynamics is to start with the fluctuation theorem (2) (valid for translation invariant model of work) and use convexity of exponential function to upper bound average work w . However, as we will soon see, if the battery has a regime of energies for which the map is not translationally invariant, the RHS of (2) can be made arbitrarily big. We thus need a different approach to obtain useful bounds. We start by decomposing average work w into two terms, each related to a different regime of the initial state of the battery. Note that using (8) we can always write average work as a sum of two terms conditioned on the initial state of the battery, that is: where we labelled: Our strategy is to bound the terms appearing in (12) using two different techniques. Rewriting the first term and using (8) we get: Notice now that channel probabilities r(s k |sk) satisfy Gibbs-preserving conditions (6). In particular, this means that all probabilities of transitions are upper bounded by associated Gibbs factors. More formally, for all s, s and k, k we must have r(s k |sk) ≤ e −β(E s −Es+ k − k ) . This implies the following simple bound: where η S was defined below (9). If we now plug this into our expression for w vac we get: where we labelled η k := Z W · e β k . Let us now move on to the second term from (12). But instead of evaluating it explicitly, consider the following quantity: where we used (8) and defined: Notice now that if the map Γ SW is just Gibbs-preserving and stochastic, then the best we can assure is that each r(s k |sk) ≤ e −β(E s −Es+ k − k ) . This implies that the RHS of (16) can grow indefinitely when the size of the battery N goes to infinity. However, for energies above min transformation Γ SW is also translationally invariant due to (7). This additional assumption combined with the Gibbs-preserving property allows to obtain a much stronger bound on (17), that is: Notice that due to (2), for an unbounded battery LHS of the above equals to 1 for an arbitrary k.
If we now write the sum from (16) for a subset of k such that k ≥ min (denoted by subscript 'inv'), we will get: Taking the logarithm of both sides and using convexity of the exponential function yields the following bound: Notice now that the quantity f s −f s inv is related to the free energy difference as ∆F S = f s −f s vac + f s −f s inv .
Using this and some algebra allows us to write: Combining upper bounds for w vac and w inv yields (9).
The proof of Theorem 1 highlights several interesting properties of thermodynamic processes operating close to the vacuum state of the battery. First, notice that the fluctuation theorem (2) or its unpacked version for a harmonic oscillator battery (17) make only sense in the regime where battery is translationally invariant. If translational invariance of the form (7) is violated for a subset of levels and the battery starts in this regime, then the number on the RHS of (17) can be made arbitrarily large. This phenomenon did not occur for a doublyinfinite battery because in that case global translational invariance implied that (7) was true for all energy levels of the battery (meaning that the battery had effectively no vacuum regime).

B. Extending thermal operations
Let us now address the second problem posed in the Introduction, that is, how to relate the results obtained using a qubit battery (wit) to those derived using a doublyinfinite weight. To do so we present a method of constructing thermal operations which cannot be realized using a doubly-infinite weight, but which can be implemented using a harmonic oscillator with the ground state.
The following construction provides a method of extending arbitrary thermal operations defined on a wit to a harmonic oscillator battery. In the Appendix we show that any operation arising from this construction is a thermal operation and in the limit N → ∞ (infinitely big battery) satisfies translational invariance of the form (7). Finally, we apply this construction to a map which takes the wit deterministically from the excited to the ground state. The work associated with this extended transformation coincides with deterministic work obtained using wit. This is the idea behind Theorem 2. In the Appendix we formally prove this, as well as present an analogous construction which distills work from the state ρ S . Finally, in the example in the last section we will see that thermal operations obtained using this construction allow to perform deterministic transformations on the system which are free from unbounded fluctuations when battery starts above its ground state.
Construction. Let Γ wit be a thermal operation acting on an arbitrary system S and a two-level battery W wit with Hamiltonian H W = ∆ · |1 1| W such that: where ρ W is an arbitrary state of the wit and the output state σ SW in full generality can be correlated. We construct thermal operation Γ osc acting on S and a battery W osc with Hamiltonian H W = ∞ k=0 k | k k | W , where k = k · ∆, by applying map Γ wit successively in the following way: 1. Apply Γ wit to the two lowest battery levels,

2.
Apply Γ wit to the next two battery levels (k, k + 1) for k ≥ 1. In this way a part of the output from previous step is processed again.
3. Repeat last step until the map is defined on the whole battery.
The resulting transformation Γ osc does not depend on the initial state of the battery for all battery states above the ground state. In other words, for all states ρ S and all ρ W such that 0| ρ W |0 = 0, the map is translationally invariant in the sense of (7).
This construction assures that in general it is possible to extend thermal operations defined on wit to infinite (but bounded from below) quasi-continous batteries in such a way that the result of the joint transformation does not depend on the initial state of the weight. As a consequence the reduced state are exactly the same for any initial state of the battery satisfying 0|ρ W |0 = 0. What is more, the channel Γ osc is fully determined by transition probabilities of its parent map Γ wit . We postpone the formal method of constructing map Γ osc from Γ wit to the Appendix and here we show instead that its construction has a simple graphical interpretation in terms of battery subchannels {R kk }. These are maps which decompose the full trace-preserving channel Γ osc into a family of completely positive trace nonincreasing (CPTNI) channels acting on S and conditioned on the battery W . Denoting initial state of the battery by ρ W = ∞ k=0 p W (k) | k k | one can always write Γ osc in terms of these subchannels as: In Fig. 3 we describe how to extend the transformation defined on a wit Γ wit to a corresponding map on a harmonic oscillator Γ osc using this decomposition.
In order to find a useful application of the presented construction let us see what happens when we demand that our battery starts and ends up in a well-defined energy eigenstate. The resulting shift on the battery precisely corresponds to the amount of deterministic work required or distilled by the protocol, possibly with some error rate ε. We have the following: Theorem 2. Let Γ wit be a thermal operation acting on an arbitrary system S and a two-level battery W wit with Hamiltonian H W = ∆ · |1 1| W and ∆ > 0 such that: Then there exists a thermal operation Γ osc which acts on S and battery W osc such that Γ osc realizes (24) on S exactly and independently from the initial state of the battery for all battery states above the ground state: This theorem has several interesting consequences. First, the existence of map Γ osc means that it is possible to have fluctuation-free deterministic work using a battery which behaves like a weight. What is even more interesting, since the battery is translationally invariant, it satisfies the second law of the form (9). In particular, if we start with a battery state that is sufficiently far from the bottom of the spectrum, then the ordinary form of the second law (1) holds. This means that the battery cannot be used to extract work from a single heat bath (which clearly could be done with wit as we show in the Appendix). In this way we obtain work which is free from unbounded fluctuations in deterministic processes and does not violate the second law of thermodynamics.

IV. EXAMPLE
Let us illustrate our main claim by studying a paradigmatic process of Landauer erasure. Suppose we are given a qubit S with Hamiltonian H S = 0 in a maximally mixed state 1 2 I S . Imagine that we also have an imperfect machine which is able to erase qubits with some small failure probability ε. Ideally we would like to take the system back to its ground state |0 0| S , but the best that our machine can do is to map the qubit with probability 1 − ε to state |0 S and with probability ε fail and output an orthogonal state |1 S . Effectively our machine performs the following operation: where We call such process -deterministic because it outputs a well-defined state, up to a small error ε. We will implement this effective transformation using three different battery models and compare any arising differences. To make our comparison rigorous let us introduce a concept of conditional work, denoted by w i and defined as the work performed by the system when a particular output state ρ i S is produced. Consider a transformation which takes ρ S to a mixture of different states ρ i S , each with probability p(i) so that running the protocol many times yields on average ρ S = i p(i)ρ i S . Then, the conditional work w i quantifies the shift of the battery W which happens when a particular state ρ i S is produced. It follows from linearity that to each possible output state ρ i S we . In the Appendix we show that for every N ∈ N channel ΓN is a thermal operation and in the limit N → ∞ becomes translationally invariant, provided that the battery starts above the ground state | 0 . Blue color corresponds to an exemplary battery subchannel for a 3−level battery, that is R Other battery sub-channels can be found in an analogous way.
. Writing this formally we have: where we denoted possible battery output states with It can be easily verified that the average of w i is just the ordinary average work w , that is: We are now ready to analyze the three battery models.

A. Wit
Let Γ SW = Γ wit be a thermal operation that performs the erasure process from (26) using wit W wit with Hamiltonian H W = ∆ · |1 1| W as the battery system. We are thus looking for the following transformation: In order to perform this transformation the value of w must be chosen such that the input state thermomajorizes the output. According to [19] (see also the Appendix) for ε < 1/2 it is enough to choose ∆ = kT log 2 + kT log(1 − ε). Our map Γ wit can output two different states on S, ρ 0 S = |0 0| S and ρ 1 S = |1 1| S with respective probabilities p(0) = 1 − ε and p(1) = ε. Regardless of the result on S, the wit always ends up in its ground state. This means that the conditional work is always the same and given by: In this sense deterministic work for wit is fixed, regardless of whether the error occurred or not during the transformation.

B. Weight
Consider now an analogous erasure process, but now taking the battery to be a doubly-infinite weight. In particular, let Γ SW = Γ weight be a thermal operation that performs (26) using a battery W weight with Hamiltonian It was shown in [9] that a necessary and sufficient condition for the existence of thermal operation realizing process (26) on a doubly-infinite weight is that for each energy level s of the output state ρ S we must have: where E i denotes the energy of i-th eigenstate of S. Notice that this is a stronger constraint than (2). In particular, when summed over an output probability distribution p S (s ) it directly implies (2). We would like to perform an analogous transformation as in the case of wit. However, as we show below, since (31) must hold for all s , we cannot enforce the same work cost when system ends in state |0 and |1 as we did somewhat for free when we used wit as the battery. If we could, then Γ weight would either violate translational invariance or would not be a thermal operation, the assumptions that led to (31). Let us thus assume that there is exactly one amount of work w 0 when we erase the state and w 1 when we fail and output an orthogonal state. Applying transformation Γ weight leads to the following output state of the system and the battery: where probabilities p(s |s) are chosen such that the transformation reduced to S correctly reproduces (26). The action of Γ weight is summarized in Tab. I. Notice that (31) implies that shifts w s on the weight must necessarily satisfy: Using (33) and (34) we can estimate the conditional work (see the Appendix for details) as: Suppose now that we want to make the transformation error ε as small as possible. By taking the limit ε → 0 we can see that the conditional work w 0 which corresponds to a successful erasure is finite and approaches the average w = −kT log 2. However, when the protocol fails and system S finishes in state |1 , the conditional work w 1 grows indefinitely. This work gain happens rarely, but prevents perfect erasure [9]. What is more, the fluctuations of work around the average increase exponentially as the probability of failure ε decreases. This indicates that there is a qualitative difference when erasing S using a doubly-infinite weight and a wit. It is worth noting that this is also true for probabilistic processes, that is those for which work is distributed according to some p(w|s, s ) for a given transition on the system. In this case both RHS's of (33) and (34) turn into a probabilistic mixture of exponents which still has to blow-up in the limit ε → 0.

C. Harmonic oscillator
Let us consider again the process from (26) but now implemented using a harmonic oscillator battery with FIG. 4. Conditional work w1 corresponding to the case when state ρ 1 S = |1 1| is produced (erasure fails). Red curve corresponds to a doubly-infinite weight (see (35)), and black curve to a harmonic oscillator battery. Note that when accuracy of the erasure process increases (ε → 0), the weight predicts that the associated work of failure diverges to +∞. In the same time, harmonic oscillator battery predicts that this work approaches the usual Landauer bound −kT log 2.
and energy separation ∆ is chosen similarly as in the first example, ∆ = kT log 2 + kT log(1 − ε). Theorem 2 tells us that to each thermal operation of the form (29) corresponds a thermal operation which acts on a harmonic oscillator battery and performs exactly the same effective transformation. This means that there exists a map Γ osc which is easily determined from the map defined on a wit (29) using the construction we described in III B. The arising map Γ osc has the following property: This holds for every initial state of the battery, provided that it starts above the ground state, that is k > min = 0. The conditional work can be found in a similar way as it was done for wit: after transformation we always find the battery in a lower state | k − ∆ , thus ρ 0 W = ρ 1 W . This implies: which coincides with the value we found when performing (26) using wit. In this way harmonic oscillator battery faithfully reproduces the amount of deterministic work needed to perform erasure for arbitrary low error rate ε.
In Fig. 4 we plotted conditional work corresponding to the case when erasure fails, w 1 , as a function of the accuracy parameter ε for both the weight and harmonic oscillator battery. Notice that when ε → 0, the conditional work w 1 diverges, whereas for oscillator it approaches the standard value of kT log 2.

V. CONCLUSIONS
We have shown that when the ground state of a workstorage device is explicitly included, the inequality formulation of the second law of thermodynamics achieves correction terms which vanish as the distance to the ground state increases.
This, however, does not imply that ideal weight can simulate real batteries when they operate far from their ground states. To show this we have studied the process of approximate Landauer erasure and shown that there is a qualitative difference in possible work distributions between batteries which posses a vacuum state and those which do not. This effect does not depend on the distance to the ground state and indicates that work fluctuations in deterministic processes reported in [9] are the results of unphysical model of a battery rather than real thermodynamic effect.
It should be emphasized that this does not mean that fluctuations of work do not appear when one introduces a ground state. Rather one should think of them as effectively hidden in the vacuum state of the battery. This means that physical batteries might not operate properly when they are in their ground states.
Finally, our results imply that introducing ground state of the battery allows to recover previous results (deterministic work) which were obtained using a wit battery. We have shown that thermal operations defined on a qubit battery can be easily extended to operations which use a harmonic oscillator instead. The extended maps act independently of the initial state of the battery and, when operating far from the vacuum, they obey the second law of thermodynamics in the standard form. We believe that this result emphasises the crucial role of the vacuum state not only in thermodynamic protocols, but also in other majorization-based resource theories when resource registers are explicitly modelled [48][49][50][51][52][53].
To summarize, ground state is a vital notion in nearly all branches of quantum physics. Our results indicate that the framework of thermal operations should be modified to account for effects associated with it. We expect that this may influence some of the results already obtained in the framework, especially fluctuation theorems for situations when batteries operate close to their ground states. On the other hand, translational invariance is a crucial concept in thermodynamics because it prevents from drawing work at the cost of battery's entropy. Even though it is impossible to introduce the ground state and in the same time keep translational invariance on the whole battery subspace, by just requiring that the battery operates in a translationally invariant way far from some threshold energy recovers desired properties of a reasonable battery model. Thus, we propose to introduce the ground state of the battery while demanding translational invariance wherever it is possible due to the existence of the ground state.

ACKNOWLEDGMENTS
We would like to thank Andrzej Grudka, Edgar Aguilar, Mischa Woods, Rafał Demkowicz-Dobrzański, Paul Skrzypczyk, Tony Short, Llouis Masanes, Marcin Łobejko and Jonathan Oppenheim for helpful and inspiring discussions. MH, PLB and PM are supported by National Science Centre, Poland, grant OPUS 9 2015/17/B/ST2/01945. PLB acknowledges support from the UK EPSRC (grant no. EP/R00644X/1). PLB is also supported by National Science Centre, Poland, grant PRELUDIUM 14 2017/27/N/ST2/01227. MH acknowledges support by the Foundation for Polish Science through IRAP project co-financed by EU within Smart Growth Operational Programme (contract no. 2018/MAB/5). This work was also supported by John Templeton Foundation.
In this Appendix we include details on thermodynamic formalism used in the main text (Appendix A) and describe three different battery models used in literature to define work in the quantum regime (Appendix B). In Appendix C we prove the general form of the second law of thermodynamics for batteries with bounded spectrum. In Appendix D we formally prove properties of the family of maps Γ osc obtained using the construction from the main text, as well as an analogous construction valid for the case when work is extracted from a quantum system. Finally, in Appendix E we study an exemplary protocol realizing approximate Landauer erasure.
Appendix A: Thermodynamic framework

Thermal operations
The setting of thermal operations consists of a system S with Hamiltonian H S that we would like to apply transformations on, an infinite heat bath B with Hamiltonian H B , initially in a Gibbs state τ B = 1 Z B e −βH B where Z B is the partition function Z B = tr e −βH B , and a battery system W with Hamiltonian H W which we do not define yet. Any joint transformation of the system S, bath B and weight W in this framework can be represented by a completely positive trace-preserving (CPTP) channel Γ SBW satisfying the following conditions (see [9,10,14,25] for a more detailed discussion): (A) Postulate I: (strict energy conservation) This implies that the energy of the joint system SBW is conserved at each time of the action of Γ SBW .
(B) Postulate II: (microscopic reversibility) The joint transformation of the system, bath and battery is unitary. Thus, there exists a unitary operator U : such that: where U U † = I SBW and H A denotes the Hilbert space associated with system A. In other words, Γ SBW has control over all microscopic degrees of freedom of the joint system SBW and no information is dumped into the environment.
(C) Postulate III: (definition of work) Before and after applying the global map Γ SBW the energy of the battery is measured obtaining outcomes |k W and |k + w W respectively. The thermodynamic work w is a random variable with probability distribution given by: where Q k = I S ⊗ | k k | W is a projector on the energy eigenspace of the battery W .
In what follows we will be interested in the joint dynamics of the system and the battery and thus the transformations we consider here are CPTP channels of the form: We will refer to any Γ SW of the above form as a thermal operation. It is important to note that channel Γ SW provides only partial information about the action of Γ SW B , but for our purposes this is enough since we are interested in the work distribution p(w). In this paper we consider processes where the input and output states of SW are both diagonal in the energy eigenbasis of the joint Hamiltonian H SBW . For such states the action of Γ SW can be fully encoded in a stochastic matrix R with elements 0 ≤ r(s k |sk) ≤ 1 defined via: Due to postulates (I-III) matrix elements r(s k |sk) must satisfy certain conditions in order to describe a valid thermal operation which takes a diagonal state ρ SW = s,k p SW (s, k) |s s| S |k k| W to some other diagonal state σ SW = s,k q SW (s, k) |s s| S ⊗ |k k| W . These constraints are: where i and E j are eigenenergies of battery W and system S associated with states |i i| W and |j j| S respectively. Condition (A6) implies that the stochastic map Γ SW is able to create state σ S from ρ S and condition (A7) ensures that the fixed point of the map is the joint Gibbs state τ S ⊗τ W = (Z S Z W ) −1 · s,k e −β( k +Es) . Conditions (A8) and (A9) ensure that R is a stochastic matrix and thus Γ SW is a CPTP channel. It turns out (see [54]) that the constraints from (A6−A9) can be satisfied by a suitably chosen stochastic matrix R if and only if the state ρ SW thermomajorizes σ SW , denoted by ρ SW T σ SW . Thermomajorization allows to determine which state transformations are possible in terms of thermal operations. The following definition was originally introduced in [22] and presented as thermomajorization in [19]: Definition 1 (thermomajorization). Let ρ and σ be two quantum states block-diagonal in the energy eigenbasis and let dim ρ = dim σ = d. The order relation of thermomajorization, denoted by T , is defined as: where p(i) and q(i) are eigenvalues of ρ and σ, respectively, reordered such that p(1) Thus, if state σ SW is thermomajorized by another state ρ SW then there always exists a stochastic matrix R with elements r(s k |sk) that satisfy (A6−A9) and it follows, due to [19], that for diagonal states there always exists a thermal operation with work Γ SW that performs this transformation.

The average and the conditional work
Let us now study work required to perform a given process Γ SW , transforming state ρ SW into another state σ SW . Consider the input state of the system and battery to be ρ SW = s,k p SW (s, k) |s s| S ⊗ | k k | SW . The average work w associated with process Γ SW is given by: where in line ( * ) we used H W | k W = k | k W and in line ( * * ) we labeled the energy difference associated with battery states | k and | k by w kk = k − k . A negative value of this quantity corresponds to a work cost (energy of battery decreases), while positive to a work gain (energy of battery increases). One can define another useful work-related quantity which we denote conditional work w i . When a transformation takes ρ to a mixture of different states σ i , each with probability p(i) so that averaging over all possible outcomes gives σ = i p(i)σ i , conditional work quantifies the work expenditure (or gain) associated with transforming into one of the states σ i . One can think about the conditional work w i as a shift on battery that happens when a particular transition takes place. From linearity it follows that for each output state there is a subchannel Λ i (not neccesarily trace-preserving) such that Λ i (ρ SW ) = ρ i SW and the full channel is a convex combination of these subchannels, that is Γ SW . More formally we have: where the conditional work for outcome ρ i S is defined as: where ρ W = tr S ρ SW and ρ i Appendix B: Thermodynamic batteries

Wit as the battery system
Originally the first model of battery in the framework of thermal operations was introduced by Horodecki and Oppenheim in [19] who considered the battery W = W wit to be a two-level system (called wit) with Hamiltonian H W = ∆ · |1 1|. This allowed to define a notion of deterministic work (see also [55]) as the difference in energy between the ground state and the excited state of the wit. Thermal operations Γ wit take then the following form: where (i, j) = (0, 1) when transformation stores work in the battery (distillation) or (i, j) = (1, 0) when transformation Γ wit consumes work (formation). Deterministic work of transition, which we denote here by w det , is defined to be the maximal (distillation) or minimal (formation) value of energy separation ∆ for which the input state thermomajorizes the output state, that is: For distillation w det yields the maximal amount of work that we are guaranteed to extract from state ρ by converting it into σ. For formation w det gives the least amount of work that has to be supplied to guarantee the transition from ρ to σ. This can be further generalized to cases where one allows the transformation to fail with some small probability ε 1. This is equivalent to finishing in some other state σ ε being ε-close to the desired output state σ according to the trace distance metric. An important result of [19] is that the absolute value of w ε det (ρ → σ) is different when transformation consumes (formation) or yields work (distillation), an embodiment of thermodynamic irreversibility on a microscopic scale. Let us denote B ε (ρ) = {ρ : 1 2 ρ − ρ 1 ≤ ε}. When we demand that the input state for transformation is a thermal state τ then the associated deterministic work is called work of formation, and according to [19] is equal to: where F max (ρ) = kT log min {λ : ρ ≤ λτ } and the minimum is taken over all states ρ that are ε-close to ρ. For the case when output state is a thermal state one defines work of distillation as: where F min (ρ) = −kT log i,g h(ε, g, E i ) e −βEi , E i is the system's energy, g iterates over degenerate energy levels in the bath and h(ε, g, E i ) ∈ {0, 1} is a binary indicator function, see [19] for details. In the classical limit (i.e. many identical copies and ε going to zero) both w ε F and w ε D converge to the difference in standard free energies F (ρ) = tr(Hρ) − T S(ρ), where S is the ordinary von Neuman entropy.
The wit allows to define a reasonable notion of work in single-shot quantum thermodynamics. Since the battery is in a well-defined state both at the beginning and at the end of the process, no entropy flows to the battery and so the energy change may be associated solely to the work exerted (or extracted) by the system. However, due to its simplicity, wit has several drawbacks. First, it does not allow to study transformations associated with a different amount of work at the same time (since the energy spacing must be tuned each time we perform a different transformation). Second, the transformation can be performed only when wit is in a specific initial state. Last, for wit only deterministic work is a legitimate thermodynamic work. The average work can easily violate second law of thermodynamics. To see this, consider a thermal operation that thermalizes the wit by performing transformation: τ S ⊗ |0 0| W → τ S ⊗ τ W . Consider w as defined in (A11) and initial state ρ SW = τ S ⊗ |0 0| W . We have: Thus, thermalization of wit yields a positive amount of work on average, in contradiction to the second law of thermodynamics.

Weight as the battery system
Recent works [9,10,17] proposed a different model of thermodynamic battery based on an ideal weight W weight with unbounded Hamiltonian H W = R dx x |x x|, where the basis is formed from orthonormal states {|x , x ∈ R} representing position on the weight. Thermal operations acting on system S and doubly-infinite weight W weight are given by a CPTP map denoted by Γ SW = Γ weight and defined as in (A2) but with an additional assumption that the global unitary U commutes with translations on the weight: where ∆ x is a generator of translations defined via the canonical conjugation relation [H W , ∆ x ] = i. It is a Hermitian operator and acts on the battery states similarly to the momentum operator: e i·∆x |a W = |a + x W for all x, a ∈ R. In other words, thermal operation Γ weight is translationally invariant and independent of the initial state of the weight. We can write any thermal operation acting on a doubly-infinite weight and initial state ρ S = s p S (s) |s s| S as: where r(s x |s) = ∞ −∞ δ(0)r(s x |sx)d x = r(s x |s 0) are transition probabilities satisfying conditions (A6-A9). The assumption of translational invariance ensures that the weight cannot be used as an entropy dump [14], meaning that the entropy of system S and heat bath B can never decrease by applying this operation. Formally, translational invariance implies that any map Γ SBW reduced to system and bath Γ SB [·] = tr W Γ SBW [(·) ⊗ ρ W ] for any initial state of the weight ρ W = ∞ −∞ p W (x) |x x| W d x, can be written as a mixture of unitaries [14]: where unitaries u x depend only on the global unitary U and not on the state ρ W . Such a mixture cannot decrease entropy of the system and the bath (but can increase). In this way energy difference of the battery may be associated solely with work exerted by (or extracted from) system S.

Harmonic oscillator as the battery system
Here we describe a battery model which will be studied further in the next sections. The model consists of a harmonic oscillator W osc with a fixed energy gap ∆ and Hamiltonian H W = N k=0 k | k k | W , where k = k · ∆ and its size N ∈ N ∪ {∞} can be also infinite. The basis is formed from orthonormal states {| k W | 0 ≤ k ≤ N, k = k · ∆} representing the number of fundamental quanta ∆ of charge stored in the battery. Thermal operations acting on this battery again have the form from (A2), however with an additional assumption that the unitary U almost commutes with translations on the battery. By almost we mean that the reduced transformation on SW effectively commutes with shifts on the battery for all states of the battery above a certain threshold energy min , provided that these shifts are not too big. Formally this means that for all s, s , k and all k such that k min ≤ k ≤ N the channel probabilities {r(s k |sk)} must satisfy: r(s k |sk) = r(s , n − k|s, n − k ), for n ∈ N such that 0 ≤ n−k ≤ N and k min ≤ n−k ≤ N . This additional assumption means that transitions corresponding to the same shift on the battery are all equal. Notice that here we write this condition in a slightly different form than in the main text (7). That form can be obtained by changing n → n − (k + k ).

Appendix C: Second law
In this paragraph we will prove a general form of the second law of thermodynamics valid for a harmonic oscillator batteries. We start by presenting several lemmas which we will use to prove Theorem 1 from the main text. Lemma 1 shows that the second law equality (derived for a weight battery in [9]) holds exactly also for fully translationally invariant harmonic oscillator batteries. However, translational invariance on the whole battery subspace is a very strong constraint and the only map which satisfies it is the identity. Because of this in Lemma 2 we demand translational invariance to hold above a certain threshold energy. Let us now define a random variable f s := E s + kT log p S (s) which occurs with probability p S (s) and whose average is the ordinary free energy, that is f s = s p S (s) [E s + kT log p S (s)] = F (ρ S ) for ρ S = s p S (s) |s s|. We have the following: Lemma 1. Let Γ SBW by any thermal operation with channel probabilities {r(s k |sk)} acting on an (N + 1)dimensional harmonic oscillator battery W and satisfying: ∀ s,s ,k,k r(s k |sk) = r(s , n − k|s, n − k ), (C1) for n ∈ N such that 0 ≤ n − k ≤ N and 0 ≤ n − k ≤ N . Then the following holds: Proof. Let us begin by unpacking (C2). The averaging is over random variables f s , f s and w according to a joint probability distribution p(s, s , w). We have: Let us now calculate the probability distribution {p(s w|s)} associated with a Gibbs-preserving map Γ SW (see Postulate III in Appendix 1): Probability distribution {p(s w|s)} describes the amount of work performed by the system while taking it from |s s| to |s s | and with battery initially in some state ρ W = k p W (k) | k k | W . Using channel probabilities {r(s k |sk)} we can rewrite (C4) as: Let us now look at the quantity appearing on the RHS of (C3): where we defined a shorthand: h(s , k) := s,k r(s k |sk)e β(E s −Es+ k − k ) . Notice now that translational invariance (C1) allows us to write: where we used n = N . Relabelling k → N − l and changing the summation variable to l = N − k further gives: where in the last line we used the fact that for a harmonic oscillator N −l − N −l = l − l and reversed order of terms appearing in the sum. Notice now that Γ SW is a Gibbs-preserving map and thus the associated probabilities r(s l|sl ) satisfy: Using this we can conclude that h(s , N − l) = 1 for each s and l, or equivalently, h(s , k) = 1 for each s and k.
Plugging this into (C6) we obtain: This allows us to write (C3) as: which proves the lemma.
Let us now see what changes when condition (C1) is satisfied only for levels with big enough energy, that is for all k such that k min ≤ k ≤ N and assuming that the initial state of the battery does not occupy levels below k min . This relaxation leads to the following lemma: Lemma 2. Let Γ SBW be any thermal operation with channel probabilities {r(s k |sk)} acting on a an (N + 1)dimensional harmonic oscillator battery W and such that for all s, s , k and k such that k min ≤ k ≤ N the channel probabilities satisfy: for n ∈ N such that 0 ≤ n − k ≤ N and k min ≤ n − k ≤ N . Then, for any initial battery state ρ W = N k=0 p W (k) | k k | W such that p W (k) = 0 for k < k min , we have: where η S := Z S · e βE max S and E max S is the maximal energy of system S and δ k := k − kmin + ∆.
Proof. Recall the following quantity: where we defined as before: h(s , k) = s,k r(s k |sk)e β(E s −Es+ k − k ) . It turns out that to prove our claim it will be convenient to work with channel probabilities rescaled by Gibbs factors, that is: For each k ≥ k min we can rewrite h(s , k) as: where in the last equation we changed the summation index to i = k − N + k min and used the fact that g s (N − k min + i|k) = g s (N − k + i|k min ) for k ≥ k min . Using Gibbs-preserving conditions and translational invariance property we can rewrite the first sum as: where we labelled A s (x) := kmin−1 l=0 g s (x|l) e β( x − l ) . Notice now that by writing Gibbs-preserving constraint (A7) for k = N − k we obtain the following relation: On the other hand for k = N − k + 1 we have: Notice now that due to translational invariance we have: we can combine (C18), (C19) and last equation to obtain: Let us now repeat this step k min times to express A s (N − k) using A s (N − k + k min ). We find: Let us now go back to our main equality (C16). Notice that the first sum on the RHS of our previous equation appears on the RHS of (C16). This allows us to write: where upper bound follows from the fact that coefficients g s (k |k) are positive for all k, k . Since we are looking for a bound which holds for all Gibbs-preserving channels we have to choose the worst-case set of channel probabilities {r(s k |sk)}. Note now that stochasticity of the channel implies that for all s, k we have s ,k r(s k |sk) = 1. For coefficients g s (k |k) this implies: where Z S is the partition function of the system S. However, due to the stochasticity constraint we cannot make each of the elements in the sum (C26) such big for all i ∈ [0, k min − 1]. The best we can do to maximize the sum on the RHS of (C26) is to set to one all channel probabilities corresponding to i which has the biggest value of e β i , that is i = k min − 1. Thus, for all s and s we choose r(s , N − (k − k min ) − 1|s, N ) = 1. This in turn gives us the following bound: where δ k := k − kmin−1 = ∆ · (k − k min + 1). Let us now come back to our starting expression from (C14). When the initial battery state as given by probability distribution p W (k) does not have support on energy levels below k min , we have: is the maximal energy of the system S.
We are now ready to prove the main theorem of this section.
Theorem 3. Let Γ SBW be any thermal operation with channel probabilities {r(s k |sk)} acting on a an (N + 1)dimensional harmonic oscillator battery W and such that for all s, s , k and k such that k min ≤ k ≤ N the channel probabilities satisfy: for n ∈ N such that 0 ≤ n − k ≤ N and k min ≤ n − k ≤ N . Then, for any initial battery state ρ W = N k=0 p W (k) | k k | W we have: where: = max s E s is the maximal energy of system S, F (ρ S ) is the free energy of the initial state ρ S and δ k := k − min + ∆.
Proof. We start by decomposing average work w into a sum of two terms: w = w inv + w vac , where w inv is the contribution arising when initial state of the battery has support on energy levels (k ≥ k min ) which satisfy translational invariance (C30) and w vac which appears when battery has support on levels which do not satisfy this constraint (k < k min ). Then we use Lemma 2 and convexity of the exponential function to upper bound w inv and finally, using the fact that Γ SW is a Gibbs-preserving channel, we upper bound w vac and obtain (C31).
Let us start the proof by writing: where we labeled w vac := w k<kmin p W (k) p(w|k)·w and w inv := w k≥kmin p W (k) p(w|k) · w. Using the definition of work (see Postulate III in Appendix A) we can write: Notice now that since channel probabilities r(s k |sk) satisfy Gibbs-preserving conditions (A7), for all s, s and k, k we must necessarily have r(s k |sk) ≤ e −β( k − k ) e −β(E s −Es) . This implies: where in the last line we labeled η S = Z S · e βE max S . Plugging this into our expression for w vac yields: where η k = Z W · e β k . Let us now evaluate the second term appearing on the RHS of (C32). We have: Since in the above k is between k min and N , we can use the result of Lemma 2 and write (see also (C29)): where · inv means that averaging is over k such that k min ≤ k ≤ N . Taking the logarithm of both sides and using convexity of the exponential function we get: where δ k := k − kmin + ∆ as before. If we now realize that we can rewrite last inequality as: Last term from the above expression can be written as f s vac − f s vac . To compute the first term let us denote x(k) := s,s ,k p S (s)r(s k |sk)f s . Moreover, notice that for any k we have x(k) ≤ max s f s . This allows us to write f s vac as: where we used the fact that for all s fine-grained free energies f s can be upper bounded by f s = E s + 1 β log p S (s) ≤ max s E s . Similarly, we can write the term f s vac as: Let us now combine all contributions to the upper bound for w inv , that is (C38), (C40) and (C41) and define : The theorem is proven by combining bounds for (C35) and (C39).
We now proceed to proving Corrolary 1. Let us denote the populations by: δ < = k<kmin p W (k), δ > = kmin≤k<k * p W (k), and 1−δ = k≥k * p W (k), such that δ > + δ < = δ is the occupation of the battery below the energy cut-off * = k * ∆. By rewriting (C35), we obtain We see that (C42) is upper bounded by On the other hand notice that the free energy difference f s − f s vac can be upper bounded as: Combining last two expressions yields an upper-bound for A β (ρ W , ρ S ): Furthermore, the correction stemming from the distance to the vacuum regime can be rewritten as with D := ∆(k * − k min ). In the limit N → ∞, we have Therefore, combining bounds (C46) with (C47), together with η S ≤ d S e βE max S , allows us to turn (C31) into a slightly weaker but more illustrative bound: with: where c S := d S e βE max S . We also explicitly marked the dependence of D( * ) and δ( * ) on a selection of threshold energy * for a given initial state of the battery.
Appendix D: Extending thermal operations defined for wit to harmonic oscillator battery

Decomposition of thermal operations into battery subchannels
Consider a thermal operation Γ SW and assume that the battery system is an (N +1)-level harmonic oscillator W N defined in [B 3]. In what follows we will denote any transformation of this type Γ SW = Γ N when N is a finite number and use Γ osc to refer to thermal operations acting on an infinite battery. Recall that by Kraus theorem [56] any channel can be written in terms of Kraus operators A sk→s k , where 0 ≤ s, s ≤ dim H S and 0 ≤ k, k ≤ N , as a sum: where A sk→s k := r(s k |sk) |s s| S ⊗ | k k | W . Coefficients 0 ≤ r(s k |sk) ≤ 1 are entries of a stochastic matrix associated with channel Γ N , as explained in Appendix A. For now we assume that Γ N is an arbitrary thermal operation acting on W N and so our only assumption about {r(s k |sk)} is that they satisfy conditions from (A6-A9). We introduce the following: kk : H S → H S for a battery W N is defined as: where A sk→s k are Kraus operators defined below (D1). Decomposing Γ N into battery subchannels R (N ) kk allows to consider the channel Γ N as a composition of subchannels acting between battery states | k and | k . In what follows we assume that the system and battery are initially uncorrelated and so ρ SW = ρ S ⊗ ρ W . Denoting initial state of the battery by ρ W = N k=0 p W (k) | k k | one can always write Γ N in terms of these subchannels as: For channel Γ 1 which acts on the system and a two-level battery we will omit the superscript N and write the corresponding subchannels as R kk . Fig. 5 presents a graphical interpretation of subchannels R kk . For our further considerations it will be useful to notice the following fact: has a battery subchannel partition Γ N [(·) S ⊗ ρ W ] = kk p W (k) R kk [·] ⊗ | k k | W the following holds: This follows from the fact that channel Γ N [·] is tracepreserving on the whole battery subspace, and thus also for each of the battery levels. One can see this explicitly by writing the channel Γ N using its stochastic matrix representation from (A5) and then using (A8).

Extending wit to a harmonic oscillator battery
We now present a formal version of the construction described in the main text. Depending on the initial state of the wit (either |0 0| W or |1 1| W ), the method of constructing map Γ N is different.
Theorem 4 (Formation). Let Γ 1 : H S ⊗ H W1 → H S ⊗ H W1 be a thermal operation as defined in (A4), acting on an arbitrary system S and a two-level battery W 1 (a wit) with Hamiltonian H W = ∆ · |1 1| W and ∆ > 0, ∆ ∈ R chosen such that: Then, there exists a thermal operation Γ N : H S ⊗ H W N → H S ⊗ H W N acting on system S and a discrete battery W N with Hamiltonian H W = N k=0 k | k k | W with k = k · ∆, 0 ≤ k ≤ N and arbitrary N (which can be infinite), which performs transformation (D5) exactly for all energies k ≥ ∆, that is: In terms of battery sub-channels R (N ) kk defined in (D2) with 0 ≤ k, k ≤ N , the extended map Γ N is given by: where ρ W = N k=0 p W (k) | k k | is the initial state of the battery and subchannels R (N ) kk are given by the following recursive relations: where • denotes the ordinary composition operation. These relations can be solved and yield an explicit (though complicated) formula for Γ N : Proof. The proof is based on showing that Γ N constructed using (D8) satisfies conditions from (A6-A9) and thus is a valid thermal operation as defined in (A4). By construction Γ N is a CPTP map at each step of iteration and thus conditions (A8-A9) are automatically satisfied. Second, if we take ρ S = s p S (s) |s s| S and σ S = s q S (s) |s s| S and assume according to (D6) that the battery starts in energy eigenstate | n n | and after the transformation goes one level down, meaning that p W (k) = δ k,n and p W (k ) = δ k ,n−1 in (A6), then (A6-A9) are equivalent to: which can be checked by direct substitution. The first of these equations means that Γ N is a Gibbs-preserving operation. We can prove that Γ N satisfies (D10) and (D11) by induction. Using the assumptions of the theorem we have: In terms of battery sub-channels R kk the above two equations can be rewritten as: Now assume that (D10−D11) hold for N −1. We will first prove the Gibbs-preserving property from (D10) and then address the state-transformation property from (D11). a. Gibbs-preserving property Writing (D10) for N − 1 using battery subchannels (D3) yields: where g W (k) = e −βkw /Z N W denote the coefficients of the battery Gibbs state τ N W . Consider now the action of Γ N on a global Gibbs state τ = τ S ⊗ τ N W = τ S ⊗ N k=0 g W (k) | k k | W . Expressing Γ N in terms of battery sub-channels gives: where we labeled: For an intuitive graphical interpretation of terms appearing in (D15) refer to Fig. 6. The basic idea behind this part of proof is to note that Γ N −2 is almost the same as map Γ N −2 constructed for a battery with N − 2 energy levels and so it preserves the Gibbs state for the bottom N − 2 levels. One then only needs to check if the Gibbs state coefficients are preserved on the remaining two levels (N − 1 and N ). Let us evaluate the terms appearing in (D15) using relations from (D8) and the induction assumption given in (D14): Using once again (D8) and (D14) yields: where in ( * ) we used (D12a ) and the fact that Gibbs coefficients g W (k) are related by g W (k + k ) = g W (k)g W (k ). Proceding similarily as in the previous case one can calculate the remaining terms of (D15): We can now plug-in the above terms into (D15) to find that: which proves that Γ N is a Gibbs-preserving map and thus satisfies (A7). This also means that it is a valid thermal operation as defined in (A3).
b. State-transformation property Let us now show the second property of map Γ N as given in (D11), meaning that Γ N is able to transform the state ρ S into σ S when battery starts and ends up in well-defined energy eigenstates. For the induction step let us assume that In terms of battery sub-channels R kk we can write this as: from which it follows that: Let us now label for simplicity the part of channel Γ N that goes to the bottom N − 2 levels of battery W N by Γ N −2 , that is: Consider now the extended map Γ N and its action on ρ S ⊗ | N N | W for 1 ≤ n < N : For the case when n = N we can proceed analogously: where in line ( * ) we used (D34 ). This completes the proof.
Let us now address the situation when ∆ < 0, that is when thermal operation Γ 1 acting on wit extracts work from system S. For simplicity we will assume that ∆ > 0 and study a transformation where wit gets excited from |0 0| W to |1 1| W . It turns out that this transformation can be extended to Γ N in an analogous way as we did in the case of state formation. The following theorem summarizes this result: be a thermal operation with work defined in (A4), acting on an arbitrary system S and a two-level battery W 1 (a wit) with Hamiltonian H W = ∆ |1 1| W and ∆ > 0 chosen such that: for all k < N and k = k · ∆, 0 ≤ k ≤ N . In terms of battery subchannels R (N ) kk defined in (D2) with 0 ≤ k, k ≤ N , the extended map Γ N is given by: kk are given by the following recursive relations: where • denotes an ordinary composition operation. These relations can be solved and yield an explicit formula for Γ N : Proof. The proof of Theorem 5 basically repeats steps from the proof of Theorem 4. The only difference is that now the battery starts in one of the states | N N | W with n ≤ N and goes one level up, meaning that the initial and final states of the battery have coefficients p W (k) = δ k,n and p W (k ) = δ k ,n+1 in (A6). Then, conditions from (A6-A7) become: Writing this conditions for N = 1 yields: Now, analogously as in the case of proving Theorem 4, we can rewrite this in terms of the battery sub-channels R kk as: The proof is again by induction. We start by assuming that (D31−D32) hold for N − 1 and then the Gibbspreserving property from (D31) follows if one uses the recursive relations from (D29). Similary, one can show that using (D29), the map Γ N satisfies (D32). In Fig. S2 we have drawn a graphical representation of the extension for the case of formation. Let us now show that in the limit as N → ∞ the average work w N (and, in fact, the whole transformation Γ osc ) becomes independent of the initial state ρ W , provided that the state ρ W does not have support on the vacuum state | 0 0 | W = |0 0| W . In what follows we will denote Γ osc [·] = lim N →∞ Γ N [·] and similarly W osc := lim N →∞ W N . Lemma 3. The work associated with map Γ osc acting on system S and an infinite harmonic oscillator battery W osc is independent of the initial state of the battery ρ W , provided that the state has no support on the battery ground state. This work is given by: Proof. Let us start by calculating energy change on a finite N -level battery W N . We will then show that in the limit N → ∞ the amount of work is independent of the initial state of the battery. Consider applying Γ SW to an arbitrary input state ρ SW . The energy change ∆E W is given by: where E (f) Let us for now assume that the battery is initially in a pure state ρ W = | k k | W , meaning that the initial energy E (i) W = k . Denoting the total number of levels above state | k k | W by n, that is n = N − k, we can calculate the final energy E In line (1) we expressed the action of map Γ SW using the expansion in terms of battery subchannels from (D8) and in line (2) we repeatedly applied Fact 1 to channels having the same power j in R j 01 . The energy change on a (finite) battery associated with transformation Γ SW can be expressed as: where n = N − k. In Fig. 8 we presented a graphical scheme representing the action of map Γ N on (arbitrary) eigenstate | k k |. Notice that if we now take the limit N → ∞, then the work w N becomes effectively independent of k and thus in the infinite limit takes exactly the same form for any convex combination of eigenstates | k k |. This implies that it is also independent of the initial state of the battery, ρ W = N k=0 p W (k) | k k | W . This proves the main claim of the lemma. As a side note recall that for diagonal states ρ S = diag(x) the action of every channel can be represented by a matrix. In this way the amount of work for infinite battery can be expressed as: whereas the effective map on S is given by a stochastic transformation M : where M = R 10 x+R 00 (I−R 01 ) −1 R 11 and diag(x ) = ρ S .
Lemma 3 allows us to propose the following corollary: Corollary 2. Channel probabilities {r(s k |sk)} associated with channel Γ osc for all values of s, s and k, k such that k ≥ k min for k min = 1 satisfy: for the values of n ∈ N such that 0 ≤ n − k ≤ N and k min ≤ n − k ≤ N Appendix E: Case-study example (deterministic erasure) In this section we present an example which explicitly demonstrates the fundamental difference between thermal operations acting on a battery with the ground state and thermal operations acting on a weight. We compare a thermal operation that performs deterministic erasure on a qubit S with trivial Hamiltonian H S = 0 for three different batteries: a wit W wit , a weight W weight and a harmonic oscillator W osc . The transformation that we want to implement is given by: where ρ S (ε) = (1 − ε) |0 0| S + ε |1 1| S is a state ε-close to a desired state |0 0| and Γ S is a thermal operation Γ SW reduced to system S, that is: Γ S = tr W Γ SW . Let us consider implementations of this process using three different types of batteries.

Wit
We start with the simplest battery model: a wit. Let W wit be a qubit with Hamiltonian H W = w · |w w| W , initially in the excited state ρ W = |w w| W . Let Γ SW = Γ wit be a thermal operation which performs the approximate erasure process from (E1): This operation can be performed using a qubit battery provided that the level spacing w is at least equal to the work of formation of state ρ(ε) given by w F (ρ(ε)) = kT log 2 + kT log(1 − ε). This can be found by comparing Lorenz curves of the joint input and output states as Let us now evaluate the conditional work as defined in (A18). First, note that the transformation Γ wit can result in two different output states on S: ρ 0 = |0 0| S and ρ 1 = |1 1| S . After the transformation wit ends up always in the ground state, no matter what was the particular action on S. It follows that the conditional work in both cases coincides and is given by −w, that is:

Weight
Let Γ SW = Γ weight be a thermal operation that implements process from (E1) using a doubly-infinite battery defined in Sec. B 2. Following our discussion in the main text, let us thus assume that there is exactly one amount of work w s (a shift in the battery state) associated with each of the possible output states on system S. Due to the assumption about translational invariance from (B8) we can start in any state of the battery ρ W , so without loss of generality we choose ρ W = |0 0| W . The action of Γ weight on the input state ρ SW = 1 2 I S ⊗ |0 0| W can be written as: where |w s w s | are battery eigenstates with the corresponding energies w s . The action of Γ weight is summarized in Tab. II. In order to compute the conditional work w i note that transformation Γ weight can again yield two different outcomes, ρ 0 = |0 0| with probability p(0) = 1 − ε and ρ 1 = |1 1| with p(1) = ε. Decomposing Γ weight into a convex sum of subchannels Λ i , that is Γ weight [·] = p(0) Λ 0 [·] + p(1) Λ 1 [·] yields: The conditional work is then simply given by w 0 = w 0 and w 1 = w 1 . We can interpret w 0 as the work of success, as this is the work associated with a successful erasure of information stored in qubit S. On the other hand, w 1 can be interpreted as the work of failure that has to be supplied (or is obtained) when erasure fails, ending up in the state |1 1| W . It was shown in [9] that the probability distribution of work p(w) must obey certain constraints in order to arise from a valid thermal operation. Precisely, for a transformation Γ SW with a weight and under the assumption of translational invariance, the associated work distribution defined in (A3) must satisfy the so-called Gibbs-stochasticity condition: where s, s denote the input and output levels of S, respectively, and w is the amount of work associated with a transformation between levels s → s . In our case we have p(s , w|s) = p S (s )δ w,w s . Plugging this into (E6) we obtain the following two constraints: Using the above we can evaluate conditional work for s = 0, 1 as: We can see that in order to achieve perfect erasure (which happens in the limit ε → 0) we must necessarily allow for work fluctuations scaling as log 1 ε . These fluctuations represent a work yield, as noted in [9]. Such events happen rarely (with probability ε), but the associated work yield can be huge (see (E10)). This prevents perfect erasure in the sense that while approaching ε → 0 the conditional work w 1 explodes to infinity. Note that this does not mean that the average work w diverges. Since ε goes to 0 much faster than log 1 ε , the contribution from w 1 effectively vanishes in the limit of small ε, yielding a finite amount of average work: In Fig. 4 from the main text we plotted the conditional work w 1 (or work of failure) as a function of ε.

Harmonic oscillator
Consider now a thermal operation Γ SW = Γ osc acting on a finite, discrete weight W N and constructed using the method provided in Theorem 4. In particular, let us start with a thermal operation Γ wit acting on a wit and system S which performs erasure process from (E1), that is: where w = kT log 2 + kT log(1 − ε) as previously. In terms of battery subchannels R kk defined in (D2) transformation Γ wit can be equivalently written as: Writing explicitly, transformation Γ wit has the following decomposition in terms of subchannels R kk : R 01 [·] = 1 2(1 − ε) 0| · |0 S |0 0| S + 1 2(1 − ε) 1| · |1 S |1 1| S , (E15) where the action of R 00 [·] and R 01 [·] is chosen such that Γ wit preserves the Gibbs-state and thus is a valid thermal operation. Using Theorem 4 we can extend Γ wit to a channel Γ N acting on an (N + 1)-level battery W N for arbitrary integer N . Here we consider the case when N = ∞, meaning that the battery is infinitely big (but bounded from below). Theorem 4 states that the map constructed in this way has the same transformation properties as Γ wit for all battery states above the ground state, that is: where E ∈ {w, 2 w, 3 w, . . .}. Note that for diagonal input states we can think of subchannels R kk as matrices, denoted by R kk and acting on vectors composed of the diagonal parts of the states. In this example we have: Elements of matrix R kk , denoted by (R kk ) ss for s, s ∈ {0, 1}, can be interpreted as transition probabilities r(s k |sk) of transforming state |s S ⊗ |k W to state |s S ⊗ |k W via channel Γ SW which we saw in conditions (A6-A9). Using this matrix notation, the composition of maps then reduces to an ordinary matrix multiplication. In our situation the precise form of the extended map Γ osc is particularly simple as matrix R 11 is equal to zero, which implies that the channel Γ osc takes every battery state above the ground state one level down, that is |E E| W → |E − w E − w| W for all E > w and for all s ∈ {0, 1}. More explicitly, our channel Γ osc has the following decomposition in terms of battery subchannels R kk : For k = 0 : For k > 0 : It is easy to see that the conditional work associated with process Γ osc is the same for all output states on S. Let us denote the vector of initial probabilities of system S with x, that is diag(ρ S ) = x. This way we can use the formula from (D47) and find that: which holds for all x. In this way the conditional work becomes: Notice that is is exactly the same as we found with wit. What is more, this quantity is finite as ε → 0. Note that we could proceed analogously for an arbitrary N −level battery, even for small N and still obtain the same amount of conditional work. Let us now study the second law equality described in the previous section. We start by first unpacking the following quantity: where we defined a shorthand: h(s , k) := s,k r(s k |sk)e β(E s −Es+ k − k ) . In order to find probabilities r(s k|sk) for the full channel Γ osc we can use the following realization: (E27)