Manuscript Offprint
arXiv:2610.33193The Thermodynamic Complexity of Circuits
Abstract
When any physical system executes a logically irreversible (non-injective) step of a computation, the excess heat released over the so-called Landauer limit is an energetic cost that cannot be recovered. In modern computers this cost vastly dwarfs the Landauer limit. Modern stochastic thermodynamics refers to this cost as the “entropy production” and has derived some very powerful lower bounds on its value, which strictly strengthen the second law of thermodynamics. Here we introduce a model of circuits using heat functions and investigate its entropy production, deriving new results on the thermodynamic complexity of circuits.
In our model, the circuits compute cleanly, erasing their inputs and all intermediate values. We first show that computing the optimal heat functions for gates in a given circuit (the gates that minimize total entropy production) when the circuit's input is uniformly random is PP-complete. We also show that multiplicative approximation of those heat functions is NP-hard, but additive approximation admits a polynomial-time randomized algorithm. We give tight bounds for entropy production for certain specific families of circuits (on uniformly distributed inputs): an n-ary AND tree of depth requires circuit entropy production, while a serial chain achieves , showing an energy-depth tradeoff. The Batcher odd-even mergesort network on n bits has entropy production, asymptotically less than its gate count. On random permutations of distinct integers its entropy production is , asymptotically exceeding the Landauer cost of sorting; but preceding it with Leighton and Plaxton's almost-sorting network reduces the total heat released to . Finally, we show that a clean sorting circuit (not a sorting network) can sort n values with zero circuit entropy production over any exchangeable input distribution. Our framework also yields streamlined proofs of known results in stochastic thermodynamics on mismatch cost and modularity cost.
A preliminary version of this paper appeared in chapter 6 of Niels Kornerup's PhD thesis [Kor25]. This version substantially improves, corrects, and builds on the results in that chapter.
Condon was supported by an NSERC Discovery grant.
Doty was supported by NSF awards 2329909 and 2211793 and DoE award DE-SC0024467.
Kornerup was supported by the LDRD Program at Sandia National Laboratories. Sandia is managed and operated by NTESS under DOE NNSA contract DE-NA0003525.
Soloveichik was supported by a Schmidt Sciences Polymath award.
Wolpert was supported by NSF award 2626044.
Contents
1 Introduction 2
1.1 Landauer's principle and logical reversibility 3
1.2 Beyond logical reversibility: Stochastic thermodynamics 6
1.3 Prior work on thermodynamics of circuits 9
1.4 Our results 10
2 Preliminaries 14
2.1 Our model 16
3 Deriving optimal heat functions 22
4 The complexity of optimizing heat functions in a given circuit 23
4.1 PP-complete language for optimizing heat functions 24
4.2 Approximation 25
5 Bounds on thermodynamic costs of fixed circuits 28
5.1 Warm-up: entropy-depth tradeoff for computing AND 29
5.2 Batcher's odd-even mergesort network 30
5.2.1 Binary inputs 31
5.2.2 Arbitrary inputs 36
5.3 A more thermodynamically efficient sorting network 44
6 Clean zero entropy circuits for compaction and sorting 46
6.1 A clean compaction circuit with zero entropy production 46
6.2 A clean sorting circuit with zero entropy production 51
7 Conclusion 53
8 Acknowledgments 55
8.1 Discussion of substantive LLM use 55
A Basic lemmas 61
B Analyzing entropy flow in Batcher's sorting network: overwriting model with binary inputs 62
C Re-deriving mismatch costs 65
D Entropy production from modularity 67
Then in the 20th century there was a similarly revolutionary invention, of computers. Accordingly, the energy required to accomplish computational objectives has been a subject of academic inquiry for a century. A deeper and more powerful understanding of this thermodynamics of computation would not just be a purely theoretical advance. As a practical matter, we live in a world where the energetic costs of computing are critically important. The International Energy Agency estimates that 485 terawatt-hours was consumed running data centers in the year 2025 and projects that this number will roughly double to 950 terawatt-hours in 2030 [Int26]. Despite this, our theoretical understanding of the fundamental thermodynamic costs of computation is rather limited, partially due to the lack of a strong and flexible model that captures many of the nuances of the thermodynamics of computation beyond logical reversibility. While current computational devices expend energy at rates well above those mandated by the laws of thermodynamics, as technology improves a principled understanding of thermodynamics is key to optimizing the energetic costs of computation.
However, most of the study of the thermodynamics of computation to date has been based on classical thermodynamics principles. While the field of thermodynamics itself has continued to evolve in recent decades, the study of the thermodynamics of computation has not kept pace. In particular, there has been a revolution in non-equilibrium statistical physics in the 21st century, resulting in what is now called stochastic thermodynamics. Whereas classical thermodynamics is, in its foundations, concerned only with systems at equilibrium, stochastic thermodynamics focuses on systems arbitrarily far from equilibrium. This makes it the ideal formalism for analyzing the thermodynamics of computation.
This paper serves two purposes: First, we introduce such a new model for investigating the thermodynamics of circuits. Our goal with this model is to strike a balance between broad accessibility to a general computer science audience and correctness with respect to stochastic thermodynamics, which represents our current best understanding of the fundamental energetic cost of machines, including computing machines. Second, we show how this circuit model can be leveraged to prove a wide range of new results ranging from the computational complexity of optimizing Boolean circuits to asymptotically tight lower and upper bounds on the thermodynamic costs of fixed circuits.
We start by giving a detailed overview of the history of the thermodynamics of computation before diving into our model and results.
1.1 Landauer's principle and logical reversibility
Most of the computer science literature on the fundamental energetic costs of computation studies reversible computing, This is an important and groundbreaking body of work, which we now summarize. Suppose a computing device executes a basic computational step that is logically irreversible, meaning that the device goes from logical state (such as the configuration of a multitape Turing machine, for instance) to logical state , where has another predecessor state that also transitions to in one step. Formally, the global transition function mapping the machine's current state to its next state is not injective. Landauer [Lan61] argued that this necessarily decreases entropy within the computing device, entropy must correspondingly increase
Notable exceptions abound in the physics literature, e.g., [WK20, YCW26, YYW26, Wol19a, WKL 24], but these papers generally use physics terms and assumptions that are often difficult for computer scientists to read.
elsewhere in the universe to satisfy the Second Law of thermodynamics. Phrased in terms of work (i.e., accessible energy), Landauer’s principle states that logically irreversible operations must expend work in order to release heat into their environments. Given a transition from n equally likely predecessor states to m equally likely successors, heat must be released, regardless of the physical implementation of the operation. Here denotes the system’s temperature and k is Boltzmann’s constant.
Landauer argued [Lan61] that most real computation would necessarily execute many irreversible operations, implying an unavoidable cost of to execute steps of a computation regardless of the physical implementation of the computing device. Bennett [Ben73] challenged this assumption, showing how to convert an arbitrary Turing machine into a logically reversible Turing machine computing the same function. The configuration graph of is then a 1D line . A completely unbiased random walk on this graph, requiring no work to bias it forwards, would then visit final configuration in time on average.
Bennett’s original construction [Ben73] simulates a t-step Turing machine in steps but pays with an increase in memory complexity up to , essentially needing to write down the entire history of the computation on a separate worktape to maintain logical reversibility, bringing the memory use up to asymptotically match the time. (Thus a polynomial-time, log-space computation, for example, pays exponentially extra memory to make the computation logically reversible.) A series of papers over the next few decades [Ben89, LS90, LV96, LTV98, LMT00, BTV01] showed various improved simulation time/space tradeoffs in reversible Turing machines; see [Ben82, Vit05, Mor08] for useful surveys. Toffoli and Fredkin [Tof77, Tof80, FT82] pioneered the study of reversible computation in other computational models such as cellular automata and circuits. Meanwhile in the physics community, there has been work on understanding the thermodynamics of logically reversible Turing machines [SCSB15b, BJO21].
So what is there to say about the fundamental thermodynamic costs of computation that has not already been said in the reversible computing literature? First, we may consider a situation in which we do not have access to a logically reversible gate set, in which we wish to understand the fundamental energetic costs associated with whatever computational devices we do have on hand. While there has been progress towards actually building logically reversible computational devices (e.g. ), these systems are not yet ready for widespread use and most computation today is performed in a highly irreversible manner. This is a deep research issue
In this paper we use the term “release heat” mostly synonymously with “dissipate heat”, but generally reserve the term “dissipate” to mean a loss of heat/work/useful energy that is irreversible. However, we are careful to include a descriptor such as “irreversible” or “irrecoverable” when we want to identify that the lose of heat/energy cannot be undone; absent this descriptor, any release/transfer of heat/work/useful energy in principle may be recovered.
In physics, it is common to specify a heat bath of temperature T. For our purposes, we can think of T as the temperature of both the system and its environment.
Throughout this paper, we choose the units for measuring energy so that . So we measure energy and heat in comparable units to bits.
Bennett [Ben73] observed that readout from such a device would be impractical, since even after waiting time, there is only a probability of observing in its final output configuration. He proposed dissipating small energy per step to bias the computation forward just enough to ensure a constant probability of finding the machine in an output configuration. This still implies energy cost for a -step computation. See [DKL 24] for arguments that this total cost need not scale linearly with , essentially by using algorithmic design techniques to increase the probability of observing the machine in an output configuration even with totally unbiased transitions, obviating the need to supply energy for even a slight forward bias. However, this trick (and the original unbiased walk outlined in [Ben73]) doesn’t account for the thermodynamic costs of resetting the device (see [Nor13, SCSB15a]). In [DKL 24] the authors avoid these costs by designing a device that never needs to be reset.
in its own right, and more practically, reflects the situation in almost every deployed computational system.
Second, over the last few decades the field of non-equilibrium statistical physics has undergone major developments, culminating in a new subfield called stochastic thermodynamics [VdBE15, Sei25]. These developments have upended our understanding of the thermodynamics of physical systems that implement computation. In particular, they reveal that the traditional understanding of logical reversibility and Landauer's principle is at best partially correct: while the Second Law does indeed imply that decreasing entropy of a system locally requires increasing entropy outside the system, nothing in the Second Law says that this must be a physically irreversible loss of work.
To give a simple example of a logically irreversible process that can be done in a physically/thermodynamically reversible way (i.e., can be done with arbitrarily little dissipated work), suppose we have a particle in a cylinder, and identify the particle being in the top half of the cylinder as a bit 1, while the particle being in the bottom half is identified as bit 0, with equal probability. So if we compress the cylinder to its bottom half using a piston, we perform a bit erasure, since afterwards the particle is guaranteed to be in the bottom half. Moreover, in first-year physics we learn that if this compression is done sufficiently slowly, then all the work expended in that compression can be recovered afterward simply by uncompressing the cylinder sufficiently slowly, returning it to its original volume, and returning the particle's distribution to equally likely to be in either half (see Szilard engines for more details, [Szi29, KMPA14]).
This is precisely the property that defines a process as being thermodynamically reversible. In contrast, if one compresses the cylinder too quickly, no matter how one subsequently uncompresses the cylinder, one won’t recover all the work that was used in the compression. This is what is meant by thermodynamic irreversibility. This example illustrates that logical and thermodynamic reversibility are independent properties of a process; it is possible to have one without the other. (See [Sag14] for a pedagogical elaboration of this point.)
Third, if the function being computed is not injective, it is not possible to compute the mapping in a logically reversibly way; instead reversible computing models typically compute . But the mappings and are fundamentally different. If is non-injective or if is prohibitively expensive to compute (i.e., if is a one-way function), then it is impossible to efficiently and reversibly obtain just from the pair One might think it is okay to just leave an extra copy of in your computer's memory, but if you compute repeatedly and old values of are overwritten, the cost of erasing these old values must be paid (see [Wol19a, Sec. 11]). One might hope to store values of generated by intermediate steps of a larger logically reversible computation and reversibly uncompute them during the uncomputation step, however, temporarily storing increases the space complexity of the overall computation (see [Ben89]).
Finally, it remains open whether every time-t, space-s Turing machine can be simulated by a
Bennett [Ben73] shows that, if is injective, it is possible to compute the mapping reversibly (i.e., not needing the input also to appear as part of the output). However, this construction has time complexity as high as the max of computing and computing , since it involves taking a direct computation of by a Turing machine and making it logically reversible in the same way that is reversibly computed. But if we want the time complexity to be no worse than that of computing , this rules out one-way functions in which has time complexity fundamentally greater than that of . Indeed, it is well-known folklore that the mapping cannot be efficiently computed in a logically reversible manner if is a one-way function: if such a computation, for example a Boolean circuit, were completely logically reversible, starting only with and ending only with , then the mirror image of such a circuit would be an equally efficient circuit computing , contradicting that is one-way.
reversible Turing machine using time and space; the current best results asymptotically increase at least one of them [Vit05], and there is an oracle relative to which this is necessary [FA17].
In this paper we start to investigate how stochastic thermodynamics can help untangle these issues.
1.2 Beyond logical reversibility: Stochastic thermodynamics
Bennett’s approach of requiring logical reversibility of every computational step is in one sense a very ambitious way to minimize energy costs by pushing the so-called Landauer cost of executing logically irreversible operations to 0, simply by removing all such operations. Li and Vitányi [LV96] investigated how it is possible to trade time and space for ‘energy’ by limiting the number of logically irreversible steps in a computation. Demaine, Lynch, Mirano, and Tyagi [DLMT16] built on this idea and proposed a generalization of logical reversibility they call semi-reversible computing, in which irreversible operations are permitted and assumed to cost bits of energy to execute (this being the natural generalization of the Landauer cost of 1 bit when and , assuming a uniform distribution on ). The total energy cost (by this definition) is then treated as a complexity measure to be minimized.
However, the more modern field of stochastic thermodynamics [VdBE15, Sei25] has generalized our understanding of the interaction of entropy and fundamental energy use in physical devices, beyond the overly simplistic assumption that each bit erasure costs energy. It has been argued [WKL 24] that stochastic thermodynamics can be fruitfully applied to computational complexity to better understand the relationship between fundamental thermodynamic costs and other traditional complexity measures such as time and space.
We now review entropy production, a basic concept from modern stochastic thermodynamics that lets us study the fundamental limits of energetic costs even for logically irreversible computation. As applied to the study of computation, we propose entropy production as a computational complexity measure/cost to be minimized. This is already the measure of interest for such systems in the physics community (i.e. [Wol19a, PP21, WKL 24, Sei25]). We then analyze these costs in a particular circuit model, noting that our approach can be extended in a natural way to other models of computation.
We provide our full definitions in Section 2 and give a semi-formal summary of the underlying concepts here. Briefly, the generalization of the Second Law of thermodynamics most central to our purpose is the equation
Equation (1) appears later in Definition 2.24 with notation specialized to the study of the thermodynamics of circuits. The terms EP and Q respectively mean entropy production and entropy flow. However, throughout this paper we focus on the case of a single (thermal) reservoir. That leads us to use the term heat released for Q. Furthermore, given our choice of units such that , we can equate information in bits with equal units of heat; we discuss these terms below.
To begin, we focus on the term in Eq. (1). represents the probability distribution on states of a physical device prior to executing a (possibly logically irreversible) step,
The stochastic thermodynamic perspective can be viewed as an “intrinsically distributional” complexity measure because it defines costs that are fundamentally tied to a distribution over inputs. In other words, there is not in general a sensible notion of “worst-case entropy production” defined as , as is typical for definitions and represents the associated distribution after; is the Shannon entropy of .
Concretely, suppose we perform the most widely discussed logical operation in the thermodynamics of computing: erasing a single bit . Here “erasing ” generally means “setting to 0”, i.e., no matter whether was 0 or 1 before, afterward it is 0 and so the system has “erased” any knowledge of ’s previous value. In this case, is the degenerate point-mass distribution with . The prior distribution may be a number of things, but the worst case in terms of logical irreversibility is the uniform distribution with , i.e., prior to erasing the bit, we have maximal uncertainty about its current value. The term , the difference in Shannon entropy between distributions and , is the so-called Landauer cost. In this example, is the simple binary entropy function on , so , , and the Landauer cost is 1 bit of entropy. Importantly, (1) means that the Landauer cost does not necessarily imply positive entropy production. By focusing instead on entropy production, we open the door to modeling and analyzing sources of heat dissipation in computation, over and above the Landauer cost, that cause EP to be positive.
The other two terms EP and Q account for how this local drop in entropy relates to the outside universe. EP, the entropy production, represents the total increase in entropy of the universe. The Second Law dictates that . This is related to the local decrease in entropy by the heat released Q corresponds to the entropy change of the environment due to heat exchange (releasing heat increases the entropy of the environment) and encompasses the underlying physical implementation of our computation. Note that to maintain the Second Law ( ), we must have . If the local entropy strictly dropped through a logically irreversible step, i.e., if , then in this case Q must be strictly positive to maintain .
The ability of randomized computation to have a negative Landauer cost has implications for energy use as well, allowing a computation to use randomized operations to counteract the heat released in other steps by logically irreversible operations. As a simple example of these principles in action, and to illustrate how the laws of physics allow for computation with zero dissipated work even if a logically irreversible step such as erasing a bit is performed, consider a situation in which we first generate a random bit and then erase it. Imagine we have some physical sort of randomness/entropy available to generate a random bit . Suppose we generate this bit in
of worst-case time or space complexity.
For example, if the system has two bits each i.i.d. 0 or 1 with probability , and if the system computes , then implied output distribution on is and .
Much literature on reversible computing assumes the Landauer cost of erasing one bit is, depending on units, 1 bit of entropy or units of heat. (In this paper we will use units of entropy, i.e., bits.) However, this assumes is the worst-case uniform distribution; for other distributions the drop in entropy is strictly less than one bit: it is precisely the binary entropy if one of the bits has probability . As an extreme example, if , then the Landauer cost is 0. Indeed, obviously it costs nothing to “set” a bit to 0 when one knows for certain that it is already 0; no action at all is required for this “computation”. More generally, Frank [Fra17] points out that reversible computing need not require a function to be fully injective, but only injective on inputs with positive probability.
The physics literature often refers to “the environment” as a “heat bath” or “heat reservoir”. We note that the term “heat” in theoretical physics does not necessarily imply anything actually getting hotter, and even in that community there can be forms of entropy flow not interpretable as heat transfer. In principle Q does not necessarily represent heat dissipation. It could correspond to discharging a rechargeable battery or increasing degrees of freedom that do not correspond to computational states (i.e. the device might write bits to a tape outside of the computer). However, in most physical devices, released heat is the form entropy flow takes, and we will use this term synonymously for entropy flow, especially since it is less easily confused with entropy production.
a memory location where we know in advance that a 0 is already written. Applying equation (1) to the first step, we have that is the point-mass , whereas afterward we have . Thus the Landauer cost is actually negative. Physically, this corresponds to the fact that in principle, one removes heat from the environment to randomize this bit, releasing the same amount of heat on the subsequent erasure step that takes us from (b is equally likely to be 0 or 1) back to (b=0). This is essentially “taking a loan and then paying it back”.
In the remainder of this paper, we focus on deterministic computation, in which every state has at most one successor. Our model may describe only part of a larger physical device: other parts may perform randomized operations with negative Landauer cost and draw heat from the environment to offset heat released by the deterministic computation. When is a (deterministic, single-valued) function being computed, we let (Definition 2.19) denote , where denotes the distribution on induced by distribution on . In this case, the data processing inequality (Definition 2.5) implies that ; i.e., a deterministic process cannot increase the entropy of a distribution.
The previous example shows that a logically irreversible operation may have zero entropy production. Next we discuss a “dual” example: an overall operation can be logically reversible, yet require positive entropy production due to “locality”, i.e., due to the fact that portions of the computation must be done in physically separate places, so that despite entropy staying constant globally, local operations must produce entropy due to lack of knowledge of rest of the state of the system. Consider three entities Alice, Bob, and Eve. Alice and Bob are at physically separate locations with no ability to communicate. Eve has a uniformly random bit b, and sends a copy of b to each of Alice and Bob. Alice must erase her bit, setting it to 0. Globally, this is logically reversible, since the mapping is injective, but since Alice “locally forgets” b, she must release a unit of heat into the environment to erase her bit, even though far-away Bob remembers b. Though this example may seem contrived and hand-wavey, it is in fact a good example of what we sometimes called modularity cost (also known as modularity mismatch cost in the stochastic thermodynamics literature, e.g., [Wol19b]): the fact that a self-contained computational module, such as a gate in a circuit, must release heat to compute an irreversible local operation, despite the fact that elsewhere in the circuit, information about the gate’s input is retained and so globally, the operation is reversible.
To summarize, (1) applied to deterministic computation of a function obeys . is a purely information theoretic term depending only on and the input distribution : the loss of entropy between the input distribution to and the induced output distribution . Reversible computing literature is concerned with making for every computational step; in this paper we allow it to be positive, though we freely and regularly use reversible computing techniques as well. is the heat released into the environment during this computation; this depends on the physics of the device computing . The Second Law of Thermodynamics states that , so since , this implies . From a complexity-theoretic perspective, we wish to minimize , since it represents a physically irreversible loss of work (useful energy). However, given a fixed to compute and distribution , we have no control over , so minimizing is equivalent to minimizing .
1.3 Prior work on thermodynamics of circuits
One perspective on the thermodynamic costs of circuits is provided by works of Michael Frank [Fra17, Fra18]. In [Fra17], Frank generalizes the conventional computer science notion of logical reversibility to include operations that, while not reversible in general, are so under a restricted subset of their inputs. He denotes such operations as being “conditionally reversible” and shows that they can be implemented to release arbitrarily little heat, so long as the gates never receive an input violating the reversibility precondition. Frank is primarily interested in conditional reversibility since it gives logically reversible gates that may be easier to implement than networks of Toffoli gates. Our work can be seen as a further generalization of this idea; in addition to allowing conditionally reversible gates to release zero expected heat on valid distributions over inputs, we consider gates that are finely tuned for the actual distribution over inputs they expect to receive. In [Fra18], Frank also points out that Q is not quite the correct measure of thermodynamic cost. He points out that the thermodynamic costs associated with Landauer’s principle is not merely the fact that Q must be positive. Rather it is that information which is dissipated as heat will rapidly become unrecoverable to the computational process, resulting in something similar to what we call a modularity cost. Frank justifies the study of logically reversible computing since it is a sufficient condition to avoid Landauer related thermodynamic costs.
Prior work by Wolpert, Kolchinsky, Caravelli, Yadav, and Yousef [WK20, YCW26, YYW26] investigated the thermodynamics of Boolean circuits using the theorems involving mismatch cost — a metric that quantifies the additional entropy production incurred by running a process on a different input distribution than the “ideal” one for given hardware. In this case, the physics of the device computing the gate may, in a sense, be “summarized information-theoretically” by an optimal input distribution , the distribution that minimizes the entropy production according to (1). They show lower bounds on the entropy production induced by running a circuit on a (potentially mismatched) input distribution , where the lower bound depends only on the logical behavior of the gates with respect to an optimal input distribution . In other words, it is possible to prove non-trivial lower bounds on the EP of a circuit without knowing any details of the physical implementation of its gates other than their optimal distributions over its inputs.
The perspective of these works is that we know an optimal input distribution for a gate, and proceeds from there to measure mismatch costs (which are a lower bound on EP). Mismatch costs are a powerful tool for analyzing thermodynamic costs without needing to specify the underlying physics, but they are cumbersome to work with. The thermodynamic accounting they provide requires viewing everything through the lens of distributions over state and costs are neither linear (with respect to the probabilities of inputs) nor local to the gates performing computation. Moreover, the optimal distribution for a gate is a counter-intuitive way to specify its behavior and such a distribution is not unique even when the dynamics of the gate are deterministic.
Nevertheless, these methods are particularly nice as with mild assumptions on the behavior of gates in a circuit (i.e. modularity or time-invariant behavior), they can prove entropy lower bounds that are truly independent of the underlying hardware.
The physical implementation does influence what is the optimal distribution. The significance of mismatch cost is that it can be measured knowing only what is the optimal distribution, i.e., the physical implementation influences the mismatch cost only through how it influences what is the optimal distribution.
There is a well defined way to handle this with mismatch costs, but it requires analyzing the pre-image of each possible output independently, but this can be messy to work with.
1.4 Our results
Here we provide a high level overview of our results and the techniques we use to obtain them.
The thermodynamic circuit model We introduce a model of circuits where each gate releases heat determined by its input value in order to perform logically irreversible computation. For a circuit to compute a function , we require it to map each input state to output state ; the 's (which have different lengths if ) denote “ancilla” wires that may be used as extra storage during the computation. In other words, the circuit must erase any “dirty” bits introduced during the computation including the original value of . The amount of heat a gate releases can depend on that gate’s input; imagine that the gate must undergo some physical process to map each of its possible input states to the correct output. Thus, we can assign a “heat function” to each gate that maps each input to an associated amount of released heat. Technically, the amount of heat released by this process may not be deterministic, so one should think of these values as being expected costs, though sometimes for brevity we may say a gate releases heat on input , understood to mean expected heat. Thanks to the linearity of expectation, this does not make a difference in the details of our model. We say a heat function for a gate is valid if it obeys the Second Law of thermodynamics (i.e. the EP in (1) is always non-negative) on every marginal input distribution. From this perspective, we connect our model to mismatch costs in Appendix C of the appendix, and show that some of the results in [WK20, YCW26, YYW26] have more intuitive proofs using heat functions. We also show how our model can be used to prove new results about the thermodynamic costs of circuits.
Recall from Section 1.2 that our goal is to minimize EP, and that once is fixed, minimizing EP is equivalent to minimizing Q. Despite this equivalence once is fixed, when we prove a one-way bound, we generally prove lower bounds on EP (i.e., negative results stating that some computation must dissipate a certain minimum amount of work that cannot be recovered) and upper bounds on Q (i.e., positive results stating that it is possible to achieve a certain computation while only releasing a small amount of heat). For deterministic computation, so a lower bound on EP is also a lower bound on Q and an upper bound on Q is also an upper bound on EP. As is typical in theoretical computer science, we will use O-notation to suppress constant factors in our bounds. Note that constant factors are important to track in the case where and . Depending on the hidden constants, the EP for such a computation could be anywhere between 0 and .
There are two important caveats with our approach in this paper. First, when discussing EP, we are implicitly assuming that the input distribution to our circuit is sampled independently from any larger context. If a copy of the input to a circuit is retained somewhere outside of the circuit, then the drop in entropy in (1) should actually be zero and we get that . When proving lower bounds on EP this is a non-issue, as the additional context can only increase the EP. When proving upper bounds on EP, we specify that we are interested in the circuit entropy production, which we define as EP under this assumption on the input distribution. Second, when giving upper bounds on either the Q or the EP of a circuit, we are operating under the “axiom” that every gate could in principle be built with any valid heat function. While the validity constraint protects our gates from violating the Second Law of thermodynamics, other physical or engineering constraints may theoretically prevent such a gate from existing. For example, speed limit theorems [SFS18] imply that, with bounds on transition rates, EP must be strictly positive in order for gates to compute their outputs in finite time and current CMOS technology is far from the thermodynamic limit imposed by validity. Thus our upper bounds should be interpreted under the “spherical cow” assumption that validity is the only constraint on realizable heat functions.
Deriving optimal heat functions In Section 3, Lemma 3.1 shows how to derive the optimal valid heat function for a known distribution over inputs. In particular if is the probability of input and is the probability of output , then any optimal heat function for computing on this distribution over inputs must satisfy on all where . This in turn is a key ingredient in proving our results in Sections 4, 5, and 6.
Hardness results and approximation algorithms for computing optimal heat functions Section 4 is concerned with computing the optimal heat functions for gates in a given Boolean circuit (so as to minimize EP), assuming the i.i.d. uniform distribution for the circuit's inputs. We first show that the problem of computing the optimal heat function for each gate (so as to minimize total entropy production of the entire circuit) is unfortunately PP-complete (Lemmas 4.3 and 4.4). Since Lemma 3.1 shows how to compute the optimal heat function for a single gate and a given input distribution to that gate, this hardness follows essentially from the fact that computing the induced input distribution for a given gate in a circuit, knowing that the circuit's inputs are i.i.d. with probability 1/2, is itself PP-complete. The (straightforward) reduction is from the PP-complete language of Boolean circuits where at least half the assignments satisfy : by adding a single erasure gate on the output, with an optimal heat function , if and only if , i.e., if and only if . Containment in PP directly follows from an algorithm that accepts or rejects depending on the relative probabilities a gate receives a specified input or another input where .
Since PP-hardness rules out polynomial-time exact algorithms, this motivates the question of whether polynomial-time approximation algorithms exist. We show that this depends crucially on the form of error. With multiplicative error, i.e., for some constant , to compute heat functions with expected value at most times optimal, then this is NP-hard, i.e., untractable unless NP BPP. There is an easy argument for this: suppose we have a Boolean formula (a special type of circuit) and want to know whether is satisfiable. If we then add an erasure gate to 's output, then for an optimal heat function , if is unsatisfiable, , i.e., it costs 0 heat to erase the output since we know it is 0. If is satisfiable, then . Thus any approximation algorithm outputting heat value will tell us whether is satisfiable depending on whether . However, this is a somewhat degenerate case, in the sense that any optimization problem permitting an optimal value of 0 has the property that no multiplicative approximation is good unless it is exact. The more interesting case is when a wire might have both bits 0 or 1 (supp() = {0, 1}), so that we have a positive optimal expected heat . We can in fact prove NP-hardness of multiplicative approximation continues to hold even in this case (Lemma 4.7).
No NP-hard problem has a polynomial-time randomized algorithm unless NP BPP; Lemma 4.7
As is common in physics, we sidestep this issue by assuming that all gates are computed quasistatically (i.e. infinitely slowly). In the limit as time to implement a gate goes to infinity, this lower bound on the EP goes to zero. We could still implement all gates in a circuit in finite time while making this cost a small constant independent of the number of gates, but we choose to do things quasistatically to simplify our analysis.
The famous and widely-believed conjecture that is the statement that NP-complete problems such as SAT have no polynomial-time deterministic algorithms that are guaranteed to get the answer correct. The statement NP BPP generalizes this to the also widely-believed conjecture that such problems have no polynomial-time implies this applies to the problem of approximating optimal heat functions with multiplicative error. However, considering additive error in approximation, we show there is a polynomial-time randomized algorithm that outputs a heat function at most plus optimal with probability of failure at most ; the running time is polynomial in the input, , and (Lemma 4.8). The idea is simply to sample uniformly random inputs to the whole circuit C to empirically estimate a distribution on inputs to a gate g in C, from which a heat function is computed via Lemma 3.1.
Bounds on thermodynamic costs of fixed circuits Having shown the difficulty in computing optimal heat functions for arbitrary given circuits, Section 5 then analyzes particular circuits and derives both lower bounds on EP and upper bounds on Q. Section 5.1 begins with a warm-up exercise analyzing the computation of the -input AND function on uniformly distributed inputs in , using only input-preserving binary-AND gates of the form and erasure gates . We show the (possibly) counterintuitive result that the most natural implementation, a tree of AND gates of depth , along with appropriate erasure gates to enable the circuit to cleanly compute the 1-bit output , has circuit entropy production , whereas the “serial” variant with depth , can be done with circuit entropy production that is only .
Section 5.2 then analyzes the -gate, -depth Batcher even-odd mergesort sorting network on Boolean inputs. When applied to Boolean values, sorting networks are circuits where every gate is a 2-input, 2-output comparator gate: computing the identity on inputs 00, 01, 11, but on input 10, swapping the bits to output 01. The main results of this section, Theorems 5.2 and 5.4, show an upper bound on Q using only distinct heat functions and a matching lower bound on EP over a uniform distribution of inputs in when using the optimal valid heat function on every gate. This bound is notable in that it is asymptotically smaller than the number of gates in the circuit, despite none of the gates performing logically reversible operations. The upper bound (Theorem 5.2) is proven by slicing the network into regions of gates that all either (1) contain a small number of gates or (2) have one input that is overwhelmingly likely. In contrast, the lower bound (Theorem 5.4) follows directly from observing that the first 3 layers of the Batcher's odd even mergesort network consist of independent copies of sorting networks on 4 bits each and that each of these networks has entropy production. In Appendix B we prove a similar upper bound on the Q for sorting bits in a more restricted overwriting model of circuits considered in other works (i.e., [YCW26, YYW26]).
Section 5.2.2 analyzes the more interesting case of the Batcher network applied to distinct values drawn uniformly at random from an ordered set . In this case, we are able to show that the entropy production must be which is tightly matched by a trivial upper bound on given using any valid heat function where the expected released heat is on all inputs. This result is rather technical to prove, but the key ingredient is Lemma 5.11, which shows that for a constant fraction of the gates in the network, if that gate receives input with probability then whenever it must be the case that for some universal constant . Since such gates must release expected heat each, we get an lower bound on . Since the drop in entropy associated with sorting is only , we can conclude that is in Corollary 5.14.
Section 5.3 presents a straightforward method for constructing a sorting network with better thermodynamic costs than Batcher on n distinct inputs drawn uniformly at random from an ordered
randomized algorithms that are allowed to get the answer wrong with small probability.
set D. This circuit has Q that is which is asymptotically optimal. Our circuit works by first using an gate network developed by Leighton and Plaxton [LP98] that sorts all but a small fraction of the inputs. After running that circuit, we apply Batcher to its output. The result, as we show in Theorem 5.18, is a sorting network with gates that only releases expected heat. By first using Leighton and Plaxton's network, the input to Batcher's will already be sorted most of the time. Thus we can use a heavily biased heat function for the gates in Batcher's that releases less heat whenever the input is already sorted.
Compaction and sorting with zero entropy production Section 6.1 shows that we can do better than Batcher by designing a bit-sorting (a.k.a., bit-compaction) circuit specifically to minimize EP, and in fact can achieve zero circuit entropy production (Theorem 6.1) on any exchangeable distribution over inputs. Note that this construction is not a sorting network, as it uses ancilla wires and more general gates than only comparators.
We do so by using standard Bennett-style “compute/copy output/uncompute” (applied to circuits) to convert any circuit computing the mapping to one reversibly computing , with only a constant increase in gate and depth complexity. Once we have in memory, we give a way to pick heat functions for erasing each bit of such that the expected heat released is exactly the drop in entropy from mapping to . The choice of heat function for erasing each is determined based on the value of and the suffix of after index , which can be computed and uncomputed in a logically reversible fashion even after has been erased. We design such a circuit based on any sorting network with gates and depth that compacts inputs with bit payloads using only constant arity gates with only gates, depth, and ancilla wires. In Section 6.2, we show how this approach can be extended to give zero circuit entropy production circuits for sorting on any exchangeable distribution over inputs.
New proofs of known results on mismatch cost and circuit mutual information using heat functions Following some basic lemmas in Appendix A of the appendix and the aforementioned analysis of Batcher's sorting algorithm in Appendix B, we prove new results connecting heat functions to mismatch costs and reprove existing results on mismatch costs using the language of heat functions in Appendices C and D. This is intended to share these insights from stochastic thermodynamics with the computer science community and better connect our heat function model with prior work on the thermodynamics of circuits. Appendix C concerns mismatch cost, which is informally defined as the extra entropy production incurred by using a gate with a heat function optimal for distribution , when in fact is the true distribution. The mismatch cost of course depends on the physical implementation of the gate. Wolpert and Kolchinsky [WK20] showed that the way this physics influences the extra entropy production is entirely contained in its optimal distribution , in the sense that the mismatch cost is precisely the information-theoretic terms , where refers to the Kullback-Leibler divergence, see Section 2. We show how this result admits a clean proof using heat functions.
Technically [AKS83] automatically gives us this result since the network only has gates, but this network is known to have prohibitively large constant factors that render it impractical.
We actually perform a slightly different logically reversible mapping for this problem to efficiently handle payloads, see the proof of Theorem 6.1 for more details.
This is useful because, as mentioned, reversible computation is automatically zero EP assuming a heat function of for all gates.
In Appendix D, we give a simple proof of a result of Wolpert and Kolchinsky [WK20], who showed that the entropy production of applying a gate in a circuit is at least the drop in mutual information between the wires in this gate and the state of the remaining wires of the circuit. We reprove this result (Proposition D.1) in the language of heat functions showing that it is an immediate consequence of the locality of valid heat functions, i.e., the fact that heat functions reference a single gate independently of the correlation of its inputs to other gates in the circuit.
2 Preliminaries
We use log to denote , and fix , , as well as when . Let be a distribution over domain and . We use to denote the probability that a random variable has value (i.e. ). Let . We will also use to denote the distribution conditioned on the sample being in . More formally, . When , we say that is undefined. We use to denote .
Definition 2.1. The Shannon entropy of a distribution D is given by
We use to refer to a vector with the value 1 in the 'th index and zero everywhere else. When thinking about function computation, we will often use to refer to the (finite sized) domain and to refer to the (finite sized) range. When needed, we will often specify and for some finite alphabet containing an element 0. We use to denote the 'th coordinate of and to denote the function 'th coordinate function of . For we use to denote the length- vector consisting of restricted to its coordinates on indices in , and to denote the set of all such vectors.
In our model, gates apply a function to some subset of the total wires in the circuit. It is useful to extend this function to an that acts on all wires of the circuit, but only modifies the wires in according to , leaving the other wires unchanged. Thus we define the following extension of a function .
Definition 2.2 (lifting function ). If for some finite set , then we can define the function as:
The following definition gives us clean notation for the distribution over states after applying a gate computing some function .
Definition 2.3 (induced output distribution). If and is a distribution over , then we use to denote the distribution over produced by first sampling and then outputting .
Note that we have defined two distinct ways to apply functions to distributions, reflecting whether the co-domain is a scalar or an entire distribution: is an example of the former, and Definition 2.3, a new distribution resulting from applying the function to a sample, is an example of the latter. Our intended meaning should be clear based off the context. However, in general we will use capital letters such as and are functions that compute some property of the input distribution whereas lower case letters are used for mappings that define new distributions.
Definition 2.4. The mutual information between two random variables X, Y is given by:
Definition 2.5 (Data processing inequality, [CT06]). Let be any function with domain and be any distribution over . Then .
Definition 2.6. The Kullback-Leibler divergence between two distributions D and is
Proposition 2.7 (Data processing inequality for KL divergence, [CT06]). Let be an arbitrary function and be two distributions over . If , then:
Definition 2.8. If X and Y are random variables over D and R respectively, then the conditional entropy of X given Y is
Proposition 2.9. If X is a random variable and f is a deterministic mapping, then
Proposition 2.10 (Gibbs' Inequality). Let be two distributions over . Then:
with equality only when .
Definition 2.11. Let be a function. We define the Gibbs distribution over with respect to , where for any , (recall )
We prove the following lemma in Appendix A.
Lemma 2.12. Let be a function. For any set where is defined, it is the unique choice that minimizes over all distributions supported on .
We use to denote the binary entropy of a Bernoulli random variable with probability p. We use the following standard inequality on .
Proposition 2.13. .
Proof.
We also require the following standard inequality.
Proposition 2.14 (Hoeffding's inequality [Hoe63]). Let U be the uniform distribution on n bits and . Then
2.1 Our model
While we will focus on circuits in this document, the ideas used in this section are sufficiently general to apply to any computational model that performs deterministic local transformations at fixed time steps.
Heat and entropy flow To simplify our math, we will assume that all computation is performed at a fixed temperature T and units are chosen such that . Throughout this paper we analyze how much entropy a computational device must release into its environment to obey the second law of thermodynamics. We will be assuming that each logical state of the machine has the same energy level and number of microstates. In principle this entropy can take many forms, but for our analysis it is safe to assume that it is always released as heat. This motivates what we will call heat functions as a way to abstract away messy details for how computations release excess entropy.
We use the term “microstate” in this paper to mean the various different physical states a machine can be in while still representing the same logical state. As a concrete example, a Boolean gate implemented with semiconductors has a logical state identified by the bits on the input and output wires, which generally will correspond to many different physical microstates, depending on the precise positions and motion of electrons in the wires.
Thermodynamic circuits We start by giving two working definitions of circuits that we use in this paper. We start with our model of circuits, which is heavily inspired by ‘serial reinitialized’ model introduced in [WK20].
This model of circuits should be familiar to readers acquainted with the quantum circuit model. For those unfamiliar with such models, recall that a standard model defines a Boolean circuit as a directed acyclic graph, where each edge represents a wire connecting exactly two gates (nodes). Instead, in our model, all information is stored in a fixed set of n wires, and gates operate on a subset (typically of -size) of these wires to update their values. However, unlike quantum circuits, we do not require gates to be unitary. Instead, they can perform any arbitrary mapping on their associated wires. While we use the language of circuits with wires and gates, this formulation works equally well to describe straight line programs where wires correspond to registers and gates correspond to operations on these registers. While we define such circuits in abstract, as is common in complexity theory, it will often be interesting to restrict them to specific gate sets (thus each gate would operate on wires independently of the total number of wires). This rules out the possibility of implementing arbitrary functions with a single gate acting simultaneously on all wires of the circuit and lets us analyze the thermodynamic costs of computations with restricted gate sets.
Definition 2.15. A deterministic circuit on inputs with gates and wires is described as an ordered collection of gates for . Each gate specifies a set and a function . On input the circuit starts in the state where for and for . The state of the circuit at step is given by . We say that wire of evaluates to when .
Note that Definition 2.15 allows to have more wires (W) than input bits (n), to allow extra “workspace” for computation. It requires all non-input wires to be initially 0. The next definition captures our notion of computing output, which similarly allows the number of output bits m to be strictly less than the number of wires W, and similarly requires that at the end of the computation, all non-output wires are 0.
Definition 2.16. We say that a circuit cleanly computes a function if on every input , wire of evaluates to if and evaluates to 0 if .
An example of a circuit that cleanly computes a the and of its inputs is shown in Fig. 1. Next we define how heat functions can augment a circuit to model its thermodynamic costs.
As with the standard DAG-based model of Boolean circuits, if one allows larger gates than , even up to a single gate taking all inputs and computing an arbitrary Boolean function in one step, then this will not give informative complexity measures. In this paper, restricting gates to operate on wires will enable stronger lower bounds on entropy production, in an analogous sense that restricting standard Boolean circuits to have -size gates enables nontrivial lower bounds on gate complexity.
This requirement of zeroing out non-output wires is particularly important in the context of thermodynamics of computing, because it forces on the circuit the obligation to erase any non-output bits left over from the computation. Absent this requirement, a circuit could appear naïvely to produce less entropy than one would expect, hiding the cost of erasing those leftover “garbage” bits. However, if one wished to reuse the circuit for a subsequent computation, since those bits would at some point need to be set to 0 to prepare the circuit for the next input. The definition of clean computation forces the circuit to prepare itself for reuse. (Note that we do not account for the thermodynamic cost of writing the input, recording the output, or replacing the old output with the new input.)
The choice to make the first m wires correspond to output is arbitrary. If a circuit places its output on other wires, logically reversible swap gates can move the output to the first m wires with no extra entropy production.

Figure 1: An example of a circuit that cleanly computes up to permutation of the wire indices. Here the red gates perform the mapping and the blue erasure gates perform the mapping . Each gate overwrites its inputs (values on wires to the left of the gate) with its outputs (values on wires to the right of the gate).
Definition 2.17. A thermodynamic circuit is a circuit where each gate computing a function with domain is assigned a heat function . On input , the gate releases expected heat into the environment.
Remark 2.18. As we are fixing the temperature, it is reasonable to view Q as expected heat release. A more generally accurate description of would be the expected entropy flow out of the system on input x.
As we will see in Appendix D, it is important to note that Q is only allowed to depend on the inputs to a gate. This represents the fact that a gate is modular and oblivious to the larger state of the circuit. Otherwise, these heat functions can in principle be an arbitrary function of D. A gate that releases heat on some input x can be thought of being designed so it is not physically possible to specify x. This conveys the notion of restricted reversibility in [Fra17], where Frank points out that some logically irreversible operations can become reversible with such restrictions on their domain. However, not all choices of heat functions are valid. The Second Law of Thermodynamics (or Landauer's costs) places constraints on the possible heat functions that can be assigned to each gate.
Definition 2.19 (Landauer cost, [Lan61]). For any function and distribution over , we define the Landauer cost function of on :
The following is a corollary of the Second Law of Thermodynamics as applied to computation of functions. As a physical law, it cannot be proven in full generality, though it can be proven within specific models. We state it formally to motivate the subsequent Definition 2.21.
Proposition 2.20 (Second law, [Lan61, Sei05]). Let be a function. Any physical process that maps every state to the state must release at least expected heat when is sampled from distribution over .
In the context of physical systems evolving according to f, this is simply the lower bound on the expected heat release (or more generally entropy flow) out of a system where all logical configurations contain the same number of microstates as given by the second law of thermodynamics. The following definition essentially formalizes our notion of a heat function being compatible with the second law.
Definition 2.21. Let be a gate in circuit computing a function with domain . A heat function is valid for if and only if, for every input distribution over , we have that:
Definition 2.21 “directly” captures what we mean by a valid heat function—no matter the distribution it obeys the Second Law—and as stated intuitively appears to require validation over all input distributions over D. The following equivalent formulation of Definition 2.21 shows that validity in fact is solely a property of the value on individual inputs x. This is the deterministic specialization of Turgut’s Theorem 1 (Eq. (1)) in the simplified setting where each logical state has the same internal entropy [Tur09]. Zhu [Zhu24] subsequently rederived the same stochastic realizability criterion from a differential fluctuation theorem; with deterministic dynamics, Zhu’s condition likewise reduces to Lemma 2.22. We give a self-contained proof of Lemma 2.22 in Appendix A.
Lemma 2.22. Let be a gate in a circuit computing a function . A heat function is valid for if and only if, for every ,
In practice, there is a large gap between valid heat functions (those obeying the Second Law) and physically realizable heat functions (which may release far more heat than the minimum dictated by the Second Law, e.g., current CMOS technology). Additional heat is released by computation to drive the physical processes that implement the logical mapping of the gate in the desired direction in finite time [SFS18]. However, valid heat functions let us prove lower bounds on the thermodynamic costs of a computation and provide a limit for the physical implementation of the computation. In this paper, we state upper bounds on thermodynamic costs that make the idealized assumption that any combination of logical gate g and valid heat function Q for g could actually be constructed. The known laws of physics neither explicitly construct such gates nor rule out their existence (in the quasistatic limit). Thus our upper bounds all implicitly require the following “spherical cow” like assumption.
Assumption 2.23 (Idealized realizability assumption). Let be any function and be any valid heat function for computing . Then we assume that it is possible to fabricate a gate that computes while releasing expected heat on each input where in the quasistatic (i.e. infinitely slowly) limit. We assume that whenever the gate is implemented in a way where it physically cannot receive such an input. In other words, the gate actually computes a restriction of on inputs where is finite.
The fact that already makes this domain restriction implicit in our model. Any distribution with support on such an input would immediately make Q infinite. Thus heat functions where on any input occurring with positive probability trivially satisfy lower bounds and would automatically make any resulting upper bound trivial.
This is well motivated. Theorem 2 of Turgut [Tur09] shows how, in an idealized model, it is possible to implement any fixed mapping from D to R where the expected released heat on every input exactly matches any valid Q. If one wishes to reject this assumption, then they should interpret all of our upper bounds on Q and EP as theoretical limits on the best possible lower bounds for these quantities that could be proven in our model. All of our lower bounds on EP and Q hold independently of this axiom.
Excess heat released by a physical process is called the entropy production [Sei12]. More formally (recall Definition 2.2 of ),
Definition 2.24 (gate entropy production). Let be a -wire circuit and be a gate in computing a function with domain for that is assigned heat function . The entropy production of on distribution over is given by:
Note is used in Definition 2.24 instead of since is a distribution on all W wires. Note that is the negation of the Landauer cost of on (Definition 2.19), thus is nonpositive by Definition 2.5. is the entropy flow/heat released (see Section 1 for discussion of this term in the broader field of stochastic thermodynamics) in the context of circuits that exchange heat with the environment through their gates.
It is necessary to define in the context of the larger circuit, since is a global property of the circuit, while is a property of the marginal distribution of on the coordinates in . We can also define a local equivalent, termed , to , which gives a lower bound on the actual entropy production . In Appendix D we show how these two quantities are related (Proposition D.1).
Definition 2.25 (local gate entropy production). Let be a gate computing a function with domain that is assigned a heat function . The local entropy production of on input distribution over is given by:
We are ultimately interested in characterizing the entropy production of a circuit. When a circuit receives some distribution D over its inputs, this could in principal be a marginal distribution where the circuit's inputs are only a subset of the variables in a larger system, with which the inputs may have mutual information that would call for different heat functions for “globally optimal” heat release for each gate. We give the following definition for the entropy production of a circuit under the assumption that its input distribution D is independent from the outside world.
Definition 2.26 (circuit entropy production). Let C be a thermodynamic circuit with gates that cleanly computes a function f with domain D. Let D be a distribution over D and be the induced marginal distribution over inputs for gate g which has heat function . The circuit entropy production of C on distribution D is given by
Note D is not the input distribution to the whole circuit, but the induced distribution on all W wires just prior to applying gate g.
EP (D) as defined above is a lower bound on the actual entropy production involved with running the circuit, as we show in Appendix D (Proposition D.1). This bound is tight when D is an independent source of randomness uncorrelated with the rest of the universe. We call this circuit entropy production because it is exactly the entropy production of the circuit as if it were isolated from its environment. We note that this is the same notion of entropy production for circuits used in prior works (i.e., [WK20, YCW26, YYW26]).
Remark 2.27. We have defined 3 separate types of entropy production in this section. Informally, is the entropy production due to using a sub-optimal heat function for gate g given its induced marginal distribution over inputs. This captures what the entropy production of g would be if its input distribution D were sampled independently of the rest of the universe. , which is always at least , captures plus additional costs due to D having correlations with other wires in the circuit. Finally is the total entropy production across all gates in the circuit under the assumption that D is sampled independently from the rest of the universe. We will be proving lower and upper bounds on throughout the body this paper and we use both and primarily in Appendices C and D where we discuss mismatch costs.
Overwriting circuits. It is worth noting that in [YCW26, YYW26] the authors use a different notion of a thermodynamic circuit than we consider here. In their overwriting model, a circuit is defined (as is common in most non-quantum circuit complexity classes) as a DAG where the nodes are labeled with gates and the in-edges define the inputs for each gate. The authors are interested in repeated runs of their circuit where the old logical configuration of each gate is overwritten one gate at a time during the next run, so the thermodynamic costs are incurred incrementally as each gate is updated and replaces its old output with the new one. The overwriting model is an accurate abstraction of the CMOS architecture; however, it places some restrictions on what is feasible with circuits from a theoretical perspective. For example a logically reversible gate in the our circuit model admits the valid heat function on all inputs. In the overwriting model, this gate must release heat when run on independently distributed inputs unless it is computing a constant function. In fact, we can see that any circuit in the overwriting model can be simulated in our circuit model, simulating a k-input, 1-output gate by using k ‘input’ wires and one ‘output’ wire in each of our gates, setting the other k - 1 wires to 0. Each gate in the simulated overwriting circuit is now a gate in our circuit model that treats the output wires of its parents (or the input) as read-only inputs and only modifies its own output wire. At the end of the computation, the values stored in all output wires for intermediate gates are erased.
Cycles of computation and changing inputs. An important subtlety with the thermodynamics of computation is how to think about the state of the device before and after a computation has been completed. Logical reversibility gives a black box way to, for any efficiently computable function , efficiently perform the mapping without releasing any heat. However, even if is injective (hence “globally” logically reversible), this does not imply a black box way to compute the mapping unless is also efficiently computable. More generally any circuit that
In the overwriting model, the validity of the heat function for a deterministic gate is entirely determined by the drop in entropy caused by erasing the old value.
As long as an overwriting circuit is run on independently distributed inputs, it is safe to assume without loss of generality that it erases the values stored in every gate before computing the new output value.
For instance, it is well-known folklore that one-way functions cannot be efficiently computed in the forward direction (outputting only cleanly as in Definition 2.16, without retaining a copy of x anywhere) using logically produces garbage in addition to its output must erase that garbage before it can be run on a new input. Failing to do so causes real issues; if one extends Definition 2.21 to probabilistic gates, then there are valid heat functions where may be negative. By using such gates, you can define circuits that appear to violate the second law of thermodynamics until you account for the increase in entropy in their mapping of inputs to outputs.
Much of the complexity associated with reuse/cycling can be simplified by thinking of the circuit as a cog in a larger machine that goes through cycles. Let's consider a circuit computing a function with total wires. At the start of a cycle, all wires are initialized to zero. Then some upstream process writes a new input into the first wires of our circuit. The circuit will perform its computation in accordance with Definition 2.15, ending in a state where the first wires contain and all other wires are reset to zero. The value can then be swapped with fresh zeroes from the downstream process that takes as its input at no cost. Resetting these values is a task for the downstream process. Note that can be defined to keep a copy of its input. Thus the standard logically reversible mapping is allowed in this model, but then is explicitly part of the output of and must be handled as such by downstream processes.
3 Deriving optimal heat functions
Now we show how to derive the optimal heat function for a known distribution over inputs. Recall that for a logically reversible operation, i.e., computing an injective function , an optimal heat function is 0 on all inputs. In this case, no matter the input distribution , since each input maps to its own unique output , , thus . If is not injective, it remains the case that any input mapping to its own unique output has zero expected heat released on input . “Colliding” inputs will release more heat the more inputs map to a single output (more precisely, the greater the total probability of inputs sharing output ): still (now strictly positive) is the expected heat released.
Lemma 3.1. Let be an arbitrary function with domain and be a distribution over . Then any valid heat function for a gate computing that minimizes the expected heat release on input distribution satisfies for all :
on all where . On where , can behave arbitrarily so long as still satisfies Lemma 2.22 on these inputs.
Note that in the finite case, is the log of the one divided by the probability that the input is x, conditional on the output being . In other words, the optimal heat function is unique up to the choice of values for inputs with zero probability under the input distribution D and whose outputs also have zero probability under the output distribution . While an earlier version of
reversible computation; Bennett's construction [Ben73, Table 2] for efficiently and reversibly computing the mapping for bijective requires both and to be efficiently computable, ruling out one-way functions.
Note that equivalently output is .
this proof appeared in [Kor25], it contained some bugs. Here we give a corrected proof of optimality and uniqueness up to the behavior of Q on such inputs.
Proof. Picking Q as in the statement of Lemma 3.1 exactly satisfies the best possible bound of:
To see that this choice is valid, we show that satisfies Lemma 2.22. For every we have:
And for every the only constraint we place on is that this quantity is at most 1.
Next we show that any heat function that minimizes the heat release on must satisfy Lemma 3.1. Let be some other valid heat function that minimizes the expected heat release on input distribution . Then per Lemma 2.22 for every , . Moreover if for some then there must be some where could have been smaller while remaining valid, and therefore could not have been optimal. Thus we can assume that for every :
This means that we can define the conditional Gibbs distribution for every . Since is valid we know that for every :
And since is a valid heat function that minimizes the heat release on the distribution we know that for every ,
as Definition 2.21 requires that this expression be non-negative for every and we need the average of these terms to be 0 to match Eq. (2). But by Lemma 2.12, we know that this implies that for every where is defined, and hence for every where ,
For where then both and can take on arbitrary non-negative values without affecting the optimality of the heat function, so long as it remains valid.
4 The complexity of optimizing heat functions in a given circuit
Here we show that computing optimal heat functions for gates in a fixed circuit is PP-hard. In light of Lemma 3.1, this hardness result is hardly surprising: computing an optimal heat function
See [AB09, Chapter 9] for a discussion of the complexity class PP. Briefly, it is the class of decision problems/languages for which yes-instances , that like NP problems, have a polynomial-length witness , furthermore have at least half of all as witnesses; see for example the language below. A probabilistic characterization (PP actually stands for “probabilistic polynomial-time”) is that there is a randomized polynomial-time algorithm for that answers ‘yes’ on input with probability at least if and only if .
requires computing probabilities induced by the circuit. Nonetheless, we view this as an overall strength of the heat function framework.
4.1 PP-complete language for optimizing heat functions
We start with the language that we will prove PP-complete.
Definition 4.1. is a set of tuples where is a Boolean circuit, is a gate in that circuit, is a potential input to that gate, and is a positive rational number. We say that if, when receives the uniform distribution over inputs, there exists some valid heat function for gate that minimizes the expected heat release on its induced marginal input distribution such that .
We note that our choice to express threshold as a rational number whose log corresponds to the optimal expected released heat is for simplicity but is not actually needed. Per Lemma 3.1 the optimal value of is always the ratio of two integer valued fractions whose numerators are at most and whose denominators are both exactly . Thus we can safely round up any obtain a rational that is the ratio of two bit integers and without changing membership in .
To show that is PP-hard, we will reduce from the following PP-hard problem [AW22].
Proposition 4.2 ([AW22]). Let be the subset of SAT instances that evaluate to 1 on at least half of all inputs. Deciding membership in is PP-hard.
Lemma 4.3. is PP-hard.
Proof. We prove this by Karp reduction from . Given a Boolean circuit , assume its output is the first wire. We modify by appending a single-wire gate that erases its input to the first wire at the end of the circuit and call our new circuit . Observe that, due to Lemma 3.1, the optimal heat function for the added gate releases at least 1 expected heat on input 0 precisely when the probability of that input is at most 1/2. Thus, precisely when .
Next we show that this language is in PP.
Lemma 4.4. .
Proof. Consider input . Let be the marginal distribution over inputs to gate when receives the uniform distribution over inputs, be the function computed by gate , , and . The value asks if the optimal heat function releases at least 0 expected heat on input . Since such a condition is trivially satisfied by the definition of heat functions, we can automatically accept such inputs. Now we assume that . By Lemma 3.1, we know that deciding if is equivalent to deciding if . We will now construct a non deterministic program that accepts with probability at least exactly when
A version of this problem where ‘at least’ is replaced with ‘more than’ was proven to be PP-hard in [Gil74]. That paper also uses the convention that PP algorithms must accept with probability strictly larger than 1/2 on yes instances. In [AW22] the authors show how to convert between these definitions of PP.
. We start by observing that this condition is equivalent to (multiplying both sides by , then subtracting from both sides)
Thus by designing a non deterministic program whose success probability is at least 1/2 when the above inequality is satisfied, we have a PP algorithm for . Importantly, note that is exactly the probability that selects some input where . We start by picking an input for uniformly at random and evaluating it on . Let be the observed input to gate and be the observed output. We then sample a Bernoulli random variable that has outcome 1 with probability . If we have , , and then we accept. If we have and then we reject. On all other patterns we accept or reject with probability 1/2. We note that this protocol accepts with probability exactly 1/2 precisely when or . In both cases we have that our input is in and thus should accept; when we have that is precisely the optimal value and when every choice of can be optimal. Given our definition of PP, this is the intended behavior.
4.2 Approximation
We first make a simple argument that if circuits are permitted to have wires where only a 0 bit can ever appear (i.e., such as the output of an unsatisfiable formula), then it is NP-hard even to approximate an optimal heat function. Fix a circuit C and let g be an erasure gate acting on the first wire at the end of that circuit. Let D be the marginal induced input distribution for g when C receives a uniform distribution over its inputs and be a valid heat function that minimizes the expected heat release on distribution D. If then we can safely set , and observe that . However, if there is any input to C that causes the first wire to evaluate to 1 before applying g, then this choice of Q will cause . Thus, for any , this choice of Q is the unique choice that satisfies when and Q can never satisfy this condition when . Therefore by fixing C to be the in Lemma 4.3, finding any multiplicative approximation to the optimal heat function for the added erasure gate is at least as hard as solving SAT.
However, this is a somewhat degenerate case, in the sense that any optimization problem permitting an optimal value of 0 has the property that no multiplicative approximation is good unless it is exact. The more interesting case is when a wire might have both bits 0 or 1 (supp(D) = {0, 1}), so that we have a positive optimal expected heat . Using a bit of machinery, we can prove that NP-hardness of multiplicative approximation holds even in this case.
Remark 4.5 (Pointwise versus expected approximation). The motivation for studying the thermodynamics of a circuit is to reduce the amount of work (i.e. useful energy) that must be irreversibly spent each time circuit is run. Ultimately we care about finding heat functions that minimize the
While this is not possible in general under standard definitions of PP, we can get the desired behavior by flipping coins. Treat all but the last of these coins as a number in binary. If we set . If we set . If then we use the final coin to immediately accept or reject without changing the correctness of our algorithm. Post-conditioned on not immediately halting, this protocol simulates the desired Bernoulli random variable.
circuit entropy production, or equivalently (since the mapping of inputs to outputs is fixed) the net expected released heat by each gate. Thus, for our approximation results, the natural computational objective is to produce any heat function where the expected released heat is within an additive (or multiplicative) factor of optimal, rather than to approximate the individual entries of the optimal heat function.
We first require a technical lemma about converting a formula to another such that, depending on whether is satisfiable, has either 1 or a much larger number of satisfying assignments. This follows by adding dummy variables to a construction by Blass and Gurevich [BG82] that converts any SAT formula on variables into another formula on variables which contains exactly one additional satisfying assignment.
Lemma 4.6. Let be a SAT instance on variables with satisfying assignments. For every , there exists another SAT instance on variables that has satisfying assignments.
Proof. We fix . When , is satisfied exactly when all and are assigned 1. When , each assignment of that satisfy now results in assignments of that all satisfy . Thus the total number of satisfying assignments is now .
Next, we prove NP-hardness of multiplicative approximation even for gates whose inputs have full support.
Lemma 4.7. Fix any . Let be a circuit receiving the uniform distribution over inputs and be a gate in . Let be the induced marginal distribution over inputs to . Let be a valid heat function for that minimizes . Finding a valid heat function for such that that is specified by a pairs of bit integers such that is impossible in randomized polynomial time even with the promise that unless .
Proof. We prove this via an oracle reduction from SAT. Let be a SAT instance on variables and be the resulting instance on variables after applying Lemma 4.6 for with constant that we will choose later. By construction, if had satisfying assignments, then must have satisfying assignments. This implies that . We convert into a Boolean circuit whose output is the first wire and then append an erasure gate to that wire to obtain circuit . Let be some heat function that minimizes the expected heat release on the induced input distribution to the added erasure gate. Since evaluates to both true and false on some input, we know that . If was unsatisfiable, then has exactly 1 satisfying assignment and . If had some satisfying assignment then . Let be a valid heat function such that . By Lemma 3.1 we know that and thus if was unsatisfiable we have:
which implies . Since must be valid Lemma 2.22 gives us:
But if were satisfiable then we must have that:
Which implies:
As long as , Eq. (3) is at least . For simplicity, we will fix to get that when is unsatisfiable. But, if has a single satisfying assignment then . Thus finding a valid heat function for this erasure gate such that tells us whether has a satisfying assignment.
The NP-hardness of multiplicative approximation is unfortunate, as being able to estimate the optimal heat functions for each of T gates in a circuit to multiplicative error c immediately gives us a thermodynamic circuit that is within a multiplicative factor c of optimal. Like all NP-hard problems, it also rules out a polynomial-time randomized algorithm unless NP BPP.
There is a polynomial-time randomized algorithm for the problem of finding optimal heat functions with additive error on the expected released heat. Finding heat functions for each of the T gates with additive error at most will give us a thermodynamic circuit where the additive error (i.e. expected excess heat dissipation) across all gates is at most . By setting we can obtain an additive error for the full circuit that doesn't scale with T. The basic idea is simple: randomly sample inputs to the circuit and use them to empirically estimate the true input distribution to the gate with add-one (or Laplace) smoothing.
Lemma 4.8. Fix any . Given a circuit where all gates act on a constant number of bits and one such gate in , let be the induced marginal distribution over the inputs to gate when receives the uniform distribution over its inputs. Let be a valid heat function for that minimizes . There is a poly time randomized algorithm that produces a valid heat function such that with probability at least .
The smoothing factor gives us a straightforward way to ensure that our produced heat function never sets on any input.
Proof. Let be the function computed by gate , be the domain of , and . We pick inputs to uniformly at random, evaluate on these inputs, and count the number of times we see each input to . Let be the obtained counts for each input to . From these counts, we define some empirical distribution and let be the optimal heat function (per Lemma 3.1) if were the actual input distribution to . We use to denote the choices of and respectively resulting from observing counts . We use to denote the distribution over the observed counts. This gives us that:
This connection between excess heat dissipation and the drop in KL-divergence associated with computing on a device optimized for the wrong distribution over inputs is well known in the stochastic thermodynamics of computation literature. Since KL-divergence is non-negative, and the expected excess heat dissipation from using to pick our choice of is at most the expected KL-divergence between and . It is known that the add-one smoothing estimator is well suited to this task. For count vector , this estimator sets . Braess, Forster, Sauer and Simon [BFSS02] showed that for any true distribution , this estimator after samples satisfies
which is at most .
Thus by using this choice of and we can set the number of samples to get that . By Markov's inequality, this means that the probability over that is at most . Since operates on a constant number of bits, is also a constant and this can be done in a polynomial number of steps.
5 Bounds on thermodynamic costs of fixed circuits
Section 4 was about efficient algorithms for finding optimal heat functions in a given circuit in order to minimize heat released on the uniform input distribution. Lemma 4.8 aside, the hardness results
A universal lower bound on EP of this form was first identified by Kolchinsky and Wolpert [KW17] and was later called a mismatch cost. The same authors expanded on this concept in [WK20] and we include and re-prove their generalized version as Proposition C.3.
imply efficient algorithms for determining optimal thermodynamic parameters are unlikely to exist in general. Nevertheless we can analyze fixed families of circuits to derive bounds in these fixed cases. We first warm up by analyzing two simple implementations of an n-ary AND function: a balanced tree (depth ), and a linear chain of (depth n), of 2-input AND gates (Section 5.1). We then study the Batcher even-odd sorting networks, analyzing first the Boolean case (Section 5.2) then the case where each wire carries a whole integer (Section 5.2.2).
For all of these results, the upper and lower bounds we show on entropy production are for (i.e. they assume that the input distribution is sampled independently from the outside world). This assumption is perhaps stronger than it looks. Since measures the total increase in entropy of the universe, this is essentially saying the inputs, which presumably came from somewhere in the universe, are distributed independently of the state of the rest of the universe. Nevertheless, upper bounds on which are smaller than Q are still worth studying. When we know that most of the released heat is offsetting the drop in entropy of the marginal input distribution. When we know that no circuit could compute the same mapping of inputs to outputs while releasing less expected heat.
5.1 Warm-up: entropy-depth tradeoff for computing AND
We note that the circuits we consider in this example are compatible with the overwriting model. Thus the bounds we show here apply equally well to that model of computation under the assumption that inputs to the circuit across runs are independently distributed.
Assume that the input is drawn from the uniform distribution over and say that you want to cleanly compute the function where is a power of two using only and gates of the form and erasure gates . Per Lemma 3.1 we know that the optimal heat functions for each of these gates depend on their distributions over inputs. Since leaves inputs untouched and it overwrites with a deterministic function only of , when inputs are independently distributed from , the optimal heat function for this gate only depends on the marginal probability distribution over . We can see this as follows for such a product input distribution :
Similarly, per Lemma 3.1, the optimal heat function for E on input distribution D is given by:
Importantly we also have that the expected heat release of these gates is given by .
With these optimal heat functions in mind, we will now analyze the local entropy production of two different fixed Boolean circuits computing using these gates.
The first we consider is the binary tree composed of gates on pairs of inputs and an initially zeroed wire . After executing each of these gates, we apply gates on the wires containing the values of and . Since each gate in this circuit is run with , they can all be implemented with the heat function , and have an expected heat release of zero. Thus it is only necessary to keep track of the expected heat release of the erasure gates. The erasure gates deployed after applying the th layer of gates are each erasing bits that have the value 1 with probability . Thus the expected heat release of each of these gates is . Since there are such erasure gates in layer , the expected heat released in this layer is . Thus the total expected heat release is
Meanwhile the circuit maps a state with n bits of entropy to only bits of entropy. By Definition 2.25, the circuit entropy production is therefore:
Which is .
Next we consider the serial circuit where the 'th gate has the AND of the first inputs as its first argument, as its second argument, and 0 as its third argument. The circuit then applies erasure gates on the wires containing inputs and . This circuit is illustrated for in Fig. 1. Again these gates can be implemented with 0 expected heat release under the promise that , so the only source of heat release are the erasure gates. There are a total of erasure gates in this circuit that erase the individual inputs and erasure gates that erase the partial products through . Since the inputs are unbiased bits, the expected heat release of these gates is per gate and across all gates. For the partial product erasures, the 'th such gate erases the value of . Again we know that the are independently and uniformly distributed bits and therefore the 'th partial erasure gate is erasing a bit that has the value 1 with probability . The expected heat release for this gate is therefore . Thus our total expected heat release for the circuit is . Since we have the same overall mapping of inputs to outputs as the binary tree case, our change in entropy is . This gives us a circuit entropy production of
which is .
Another way one could compute the circuit entropy production of these circuits would be to use Proposition D.1 and sum up the drops of mutual information associated with executing each gate. Since the gates we are considering here are each locally optimal, this would give us the same values of that we computed here. Doing so is the primary approach used in prior works (i.e. [YYW26]) to produce lower bounds on the local entropy production of circuits. By using heat functions, we can exactly compute the circuit entropy production by only analyzing the local behavior of the individual gates. This lets us ignore more global properties of the circuit like the drops in mutual information, making our approach better suited to analyzing complex circuits where these mutual information terms are hard to quantify.
5.2 Batcher's odd-even mergesort network
We now give bounds on the circuit entropy production of Batcher's odd-even mergesort network [Bat68]. We note that the Landauer cost of a sorting network acting on bits chosen uniformly at random is , since for an input with exactly 0's, it collapses different inputs to the single output . As a result, by Proposition 2.20 applied to the whole circuit, any sorting network necessarily releases heat at least . In this section we show that the Batcher network gates can be assigned heat functions meeting this bound on heat released: (Theorem 5.2). It remains an open question whether entropy production is necessarily in any sorting network but we are able to show that the Batcher's odd-even mergesort network on binary inputs does have cost (Theorem 5.4). We then turn to the integer case, where the Landauer cost (i.e. drop in entropy) of a sorting network acting on a uniformly random permutation of is . In this case, however, we show in Theorem 5.13 that, when the input is the distribution resulting from picking elements of an ordered set without replacement uniformly at random, then Batcher's network releases heat with optimal heat functions, which is directly proportional to the size of the network. In Theorem 5.18 we leverage a sorting network of Leighton and Plaxton [LP98], to obtain a sorting network with size but only heat dissipation. In contrast, by generalizing to a sorting circuit with more than wires, it is possible to achieve zero circuit entropy production; see Section 6.1.
The Batcher network is illustrated in Figure 2 with inputs. Each vertical line represents a comparator, which sorts two bits, putting the smaller of the two on the “upper” line, i.e., the line with the smaller index, and the larger on the “lower” line. If then we say that the comparator gate . For simplicity in this section, we will assume that the number of sorting inputs is a power of two.
More formally, we will index wires for for being a power of two. We use to denote the value stored in wire after layer . By the definition of Batcher's, we know that and as these two halves of the input were sorted during the previous recursive step. We denote a comparator gate acting on indices and with as . Let . For layer 1 our set of gates is
The set of gates at layer are
To account for the total number of comparators needed, consider first the number in the non-recursive part (layers 1 to ). We have that and
where the two terms account for the separate sorting of odd-numbered bits and even-numbered bits, and the accounts for the last layer. Therefore, . Now let be the total number of comparator gates needed to sort bits. We have that and for ,
Therefore .
5.2.1 Binary inputs
We first consider the case where the input to be sorted is a length n bitstring selected uniformly at random. It is known that the correctness of a sorting network can be determined by only checking its behavior on such inputs.

Figure 2: Recursive case of Batcher's odd-even mergesort network for 16 inputs. The base case is n = 4 is shown in Figure 3.
Proposition 5.1 ([Knu98]). A sorting network on n inputs from any ordered set is correct iff it correctly sorts all inputs in .
The binary input restriction allows for comparator gates to be implemented in a more thermodynamically efficient way. This is because the inputs and are the unique pre-images of outputs and respectively, meaning that we can set and we only need to optimize the values of versus which both map to output .
Theorem 5.2. When given the uniform distribution over input x in , there is an assignment of heat function to every gate that results in the circuit releasing only expected heat across all gates. Moreover, the construction need only use distinct heat functions.
Proof. We start by bounding the expected heat released in each layer of the non-recursive merge step. We will use three different types of heat functions in this construction. is defined such that when and when . This is an unbiased heat function that we will use either when inputs and are overwhelmingly common or when the number of gates in a group is sufficiently small. This heat function has the advantage that neither input or input releases too much heat in expectation. We also define parameterized by such that , , and . Intuitively, these functions are used to reduce the expected heat released by gates where the first input is heavily biased towards input 0 while the second input is heavily biased towards input 1. In particular, if a gate receives a marginal induced input distribution where the probability of input is at most , then the expected heat released by this gate is at most . Likewise we define such that for . These gates are used when the first input is heavily biased towards 1 while the second input is heavily biased towards 0. By the same reasoning as , if a gate receives a marginal induced input distribution where the probability of input is at most , then the expected heat released by this gate is at most . In each layer , we split gates up into one of three regions depending on the value for the gate and use the same heat function for every gate in the region. We use closed intervals on regions to cleanly handle non-integer values; this has the side-effect of counting some wires as belonging to multiple regions and thus using different heat functions. We will analyze such wires as being a part of both regions and account for costs associated with both heat functions. This only increases our upper bound and significantly simplifies the analysis. Let be some value in that we pick later and for now assume that .
Layer 1 In this layer, we have that . The upper region contains all gates with and uses the heat function . Since we know that and and the input was distributed uniformly at random, Proposition 2.14 gives us that the probability that as well as the probability that are each at most . Thus by a union bound, the probability that gate receives input is at least and so the expected released heat by every such gate is at most .
The middle narrow band contains all gates with and uses the heat function . There are a total of gates in this band that each release at most 1 expected heat.
The lower region contains all gates with and uses the heat function . Using a symmetrical argument to the upper region case, Proposition 2.14 gives us that the expected released heat of every gate in this region is at most .
Putting all of this together, the heat released in the first layer is at most .
Layer 2 In this layer, we have that . The upper narrow band contains all gates with and uses the heat function . There are at most gates in this band that each only release at most 1 expected heat.
The middle region contains all gates with and uses the heat function for some specified later. By the construction of Batcher's odd-even mergesort, we know that . Thus, by Proposition 2.14, the probability that is at most the probability that or which is at most . Thus the probability each gate in this region receives the input is also at most . Picking and gives us that and thus the expected heat released by any gate in this region is at most .
The bottom narrow band contains all gates with and uses the heat function . There are only gates in this band that each only release at most 1 expected heat.
Putting all of this together, the heat released in the second layer is at most .
Layer 3 and beyond The following claim gives us that, after layer 2, most 0's are already in the top half of wires and most 1's are already in the bottom half of wires.
Claim 5.3. Let . Except with probability , the following hold for every :
-
The number of i such that i < n/2 and is at most .
-
The number of i such that and is at most .
Proof. We start by proving this for .
For , . We have already established using Proposition 2.14 that when , each except with probability at most . By a union bound, the probability that there exists such an with is at most . We give no bounds on the values of for , but we note that there are only such wires.
For , . Again we have already established using Proposition 2.14 that, when , both and each equal 0 except with probability at most . Thus by a union bound, their max is 0 except with probability at most . By a union bound, the probability that there exists such an with is at most . We give no bounds on the values of when , but we again note that there are only such wires.
For the proof is symmetric. By a union bound, the total failure probability across both halves of the argument is at most and we have excluded only wires from each half of the analysis. Note that after applying each comparator gate, the number of 1's in the first wires can only decrease while the number of 1's in the last wires can only increase. Thus the bound will automatically extend to all .
Next, we partition the gates in layer into three groups each. The upper gates are such that and they will use the heat function . By Claim 5.3, except with probability , at most upper gates receive an input other than . Thus, except with probability at most , the upper gates collectively release at most expected heat. With probability at most , every upper gate releases at most 1 heat. Since there are at most such gates in a layer, the expected heat released by all upper gates is at most .
The lower gates are such that and they will use the heat function . The reasoning is symmetric to the upper gates, so we get that the expected heat released by all lower gates is also at most .
The crossover gates are where but and they will use the heat function for some that we will specify later. By Claim 5.3, except with probability , there are at most crossover gates that receive the input . When this is the case, the expected heat released by all such gates is less than . When this is not the case, there are gates that each release at most expected heat. Thus the overall expected heat released by the crossover gates is less than . Picking when makes and therefore this expression at most .
Thus, in total, the expected heat released in each layer is less than .
Putting it all together The total expected heat released in layers 1 and 2 is while the total for layers are each , which gives a total of across all non-recursive layers. Fixing our choice of makes this expression . Since layer 0 is two recursive calls on the halves of the input, we have that if is the heat released for inputs of size , then for all . When we use for all gates and, since the number of gates in this circuit is constant, we also get a constant upper bound for the expected heat released in this base case. Since the last term in the recursive case is sub-linear, the master theorem gives us that is . We use heat function across all recursive calls and we use both and for at most 1 unique value of each per recursive call. Thus there are at most unique heat functions used in this construction.
In Theorem B.1 of the appendix, we give a similar proof showing that in the overwriting circuit model (see Section 2), Batcher's sorting network can still be implemented with only total expected heat released.
The bound in Theorem 5.2 is asymptotically tight. We can show that the circuit entropy production of sorting n bits is also .
Theorem 5.4. When given the uniform distribution over inputs in , for any choice of valid heat functions for each gate in Batcher's odd-even mergesort, the circuit entropy production is .
Proof. We show that each base case of sorting inputs has constant circuit entropy production. Since this base case occurs times in the overall sorting network and circuit entropy production is always non-negative, the entropy production of the entire circuit must be . We now analyze the sorting network, as shown in Figure 3, on the uniform distribution over inputs. The two gates in the first layer each receive inputs 00, 01, 10, and 11 with probability . By Lemma 3.1 this means that the expected heat release of each of these gates when given the optimal heat function is and the expected heat released in the first layer is 1. After the first layer, the first and third wires independently have value 1 with probability each while the second and fourth wires independently have value 0 with probability each. Thus by Lemma 3.1 we get that the expected heat release of these gates when given the optimal heat function is and the expected heat release in the second layer is . The final gate is a bit more tricky to analyze. Looking at all 16 possible inputs to the circuit, this gate receives input 00 on all inputs to the circuit with 3 or more 0's. Likewise the gate receives input 11 on all inputs to the circuit with 3 or more 1's. The gate receives input 01 on inputs 0011 and inputs 1100 to the circuit while the gate receives input 10 on each of the four remaining inputs with 2 zeroes and 2 ones to the circuit. Thus by Lemma 3.1 the expected heat release of this gate is . Putting all of this together, the expected heat release of a 4 input sorting networks is . Meanwhile the circuit maps a uniformly random length 4 bit-string to a binomial distribution on 4 unbiased coin flips. The entropy of this output equals
and so the drop in entropy is . Since the released heat is , the circuit entropy production of the 4 input Batcher's sorting network with optimal heat function is at precisely 1/8. Since the general Batcher's odd-even mergesort network features this sub-circuit on this input distribution times, the overall circuit entropy production of the network is at least which is .

Figure 3: The n = 4 base case of Batcher's odd-even mergesort.
5.2.2 Arbitrary inputs
We now consider using Batcher’s odd even mergesort for sorting a random permutation of the set . This case is actually sufficient to upper bound the minimal heat dissipation for sorting arbitrary list of distinct items from an ordered set .
Lemma 5.5. Let C be a sorting network on n inputs. Let be the uniform distribution over permutations of and be the distribution obtained by sampling n elements of D uniformly at random without replacement. Then the minimum expected heat released by any gate g in C on input distribution is at most the minimum expected heat released by g in C on input distribution .
Proof. Let be a random variable over the inputs to gate induced by receiving input sampled from and be the unordered set of values in . Using Lemma 3.1, the optimal heat function for would give a minimum expected heat release of
After conditioning on , we can re-label the elements in so that the elements in get mapped to in their relative rank order and all remaining elements get mapped to distinct values that are all at least . After this relabeling, conditioned on is just a random variable for the induced marginal input distribution when has input distribution . Thus the expected minimum heat dissipation on is at least that on .
Thus we will be assuming input distribution in the rest of this section. By Lemma 3.1 the optimal heat function for our comparator gates on marginal induced input distribution when is given by:

Figure 4: A plot of empirically calculated expected released heat per gate for sorting randomly permuted integers . The algorithm in Lemma 4.8 is used to find approximate heat functions for each gate and then a fresh source of randomness is used to compute the empirical expected heat release. Teal indicates low heat release and orange high heat release. While it appears that there are many orange gates at the beginning of each recursive step, in the later layers this number is only . Thus we use the centrally located orange gates in the later layers of each recursive step to obtain our bound.
(5)
This means that to prove a lower bound on the expected heat release, it is sufficient to show that there are comparator gates where, on their induced marginal input distribution , for every pair we have that there are universal constants such that . In particular, the gates that we show have this property will be ones that are centrally located and in the later layers. An empirical plot of the expected heat released per gate in Batcher's odd-even mergesort when is shown in Fig. 4.
Notation and network properties In order to show that these gates have similar probabilities for inputs and , we need some properties about the Batcher's odd-even mergesort network. Some of the stated properties below are already established (see, e.g., [Bat68, Knu98]), but the key technical lemma that we require (i.e., Lemma 5.11) appears to be new.
Fact 5.6. For every , we have that
Proof. For every we know that every has . Thus, comparator gates up to level can only shift the index of elements within these congruency classes.
The following basic fact about Batcher's odd-even sorting network follows directly from the original proof sketch of the network's correctness by Batcher [Bat68]. Hinze and Martin [HM18] give a proof of this result similar to the one we include here.
Proposition 5.7. After layer of Batcher's odd-even mergesort, the values stored on wires whose indices are congruent mod are in their relative sorted order.
Proof. We prove this by induction on increasing. In the base case of , we have that and the congruent pairs are the ones that were just compared. Now assume that this holds after layer and let . Fix any such that . We will show that this holds for the wires whose indices are congruent to . Let be the 'th wire whose index is congruent to and be the 'th wire whose index is congruent to . In other words is the wire at index and is the wire at index . Note that for all , . By the inductive hypothesis, we know that
for all . We also know that since they are on the same half of the input after the recursive call in Batcher's. Since the are a sorted version of the 's and likewise the are a sorted version of the 's due to Fact 5.6, this implies that
for all . By a similar argument we know when it must be the case that by the recursive call in Batcher's. This maximum of one violation comparing to gives us that in the sorted orders before applying layer ,
for all . Putting this together we have that:
for all . We now have that . We know and since pairs and are compared in layer . Also we know that and since is smaller than both possible values of and is larger than both possible values of . Doing this analysis for all completes the proof.
Lemma 5.8. Let be the gate for and . If Batcher's odd even mergesort receives some permutation of as its input, then the smaller input to is in the set and the larger input to is in the set .
Proof. We prove this by induction on decreasing. When we have that the smaller input to must be and the larger input to must be since the output after this layer is sorted. Now assume the claim holds for all gates in layer . Now we split into two cases.
When then in layer we know that wire is an input to the gate and wire is an input to the gate . By our inductive hypothesis, this means that and .
When then in layer we know that wire is an input to the gate and wire is an input to the gate . Again our inductive hypothesis gives us that and .
Next we state the key technical lemma that we will need to prove our lower bound on . We need the following definition of central gates in order to state our key lemma, and will use the definition of the hypergeometric distribution in the proof:
Definition 5.9. We say a gate is central if .
Definition 5.10. Let denote the probability that when items are taken without replacement from a set of items of which exactly are marked that exactly marked items are taken. This is given by the hypergeometric distribution:
which has mean nK/N. The distribution may have one or two modes, which differ by at most 1 from the mean.
Lemma 5.11. Let be a sufficiently large power of two and be a layer in Batcher's odd-even mergesort on inputs. Let be a central gate and be the marginal distribution over input pairs to induced by giving the sorting network a uniformly random permutation of the set as input. Then there is some constant (independent of ) such that for every ,
Before we more formally prove this lemma, we give a detailed and more intuitive outline of the strategy. We want to show that if there are permutations of resulting in a gate receiving any feasible input , then there must be at least permutations of resulting in receiving input . To prove this, we first note that due to the structure of Batcher's odd even mergesort, if then the top wire inputs to will have some fixed rank among the values of all wires after layer zero (the recursive step, which separately sorts the first and second half of the inputs independently) whose indices are congruent to , and bottom wire inputs to will have rank among the values of all wires after layer zero whose indices are congruent to . This observation is an immediate consequence of Proposition 5.7. We call these sets and respectively, since they correspond to indices plus either odd or even multiples of respectively.
With this, we now know that the top input to is always the 'th ranked element of while the bottom input to is always the 'st ranked element of . To prove our lemma, it is sufficient to show that the number of permutations of that lead to being the 'th ranked element of and being the 'st ranked element of is within a factor of of the number of permutations resulting in being the 'th ranked element of and being the 'st ranked element of .
Unfortunately, this is complicated by the fact that the indices of elements after layer zero (and hence our sets and ) are the result of independently sorting the first half and the second half of the input. Thus the sets and are determined entirely by which inputs started on which half of the wires. We introduce sets A and B containing the values stored on the first and second half of the wires at the beginning of the circuit respectively. Note that, for the uniformly random permutation of [n] as input, the induced equipartition of [n] into A and B is selected uniformly at random. Then the sets and are entirely determined by A and B.
Let and be the smaller and larger values respectively among . We observe that shifting exactly elements from to (or from to ) that are smaller than and moving elements larger than back results in flipping the sets and , which has the effect of swapping the order of the two inputs to . Moreover for any and resulting in receiving input , swapping any number of elements smaller than between and and doing likewise with elements larger than will maintain the fact that receives input . Thus we want to compare the number of possible with elements smaller than and a fixed subset of in with the number of possible with elements smaller than and the same fixed subset of in . The remainder of the proof is a (somewhat cumbersome) argument that these values are within a factor of of one another.
We use to denote the set of all that have and exactly elements smaller than in . The relative size of these sets for different values of are hyper-geometrically distributed; the ‘marked’ items are elements smaller than and we want to count how many of them end up in set . Since the probability mass function of the hyper-geometric distribution starts off monotonically non-decreasing until hitting some mode and then is monotonically non-increasing, we immediately have that when it must be the case that and we are done.
When the analysis is more involved. We show that the ratio of the squared geometric mean of and to the value of is at least some constant, , by expressing as a telescoping product. With this lower bound in hand, we can use the arithmetic, geometric mean inequality to deduce that . This in turn gives us that if is the number of choices for resulting in receiving input then we always have that as desired.
Proof of Lemma 5.11. Let . As in the proof of Proposition 5.7, we define wires indexed at and indexed at . Let and be the set of values found in the and the respectively. By Proposition 5.7 we know that the and the contain the values in and respectively in sorted orders. Let be the index such that . Thus we know that the input to is the pair .
Next we characterize the sets and . Let and be the uniformly random equipartition of our input elements into the first and second halves of the wires respectively at the beginning of the circuit. If are the elements of and are the elements of , then we know that for all and for all at the end of layer zero. Then we can characterize our sets as
and
Thus we know that any exactly when or for some . Likewise exactly when or for some .
Now define and as the min and the max respectively of and . It follows from Lemma 5.8 that
Since is central, we have that
and so both and are .
Observe that moving precisely elements from to (or from to ) that are smaller than and moving elements larger than back results in flipping the sets and . In particular such a change would swap the values of and , as the even and the odd sets swapped their values in this interval and the moved elements made the number of elements smaller than now in one more than the number of elements smaller than previously in . This swap would have the effect of replacing input with and vice versa.
Let be the (possibly empty) subset of equipartitions where and . Importantly, all equipartitions in result in receiving the same input. Then we can precisely characterize the size of these sets by:
To see why the hypergeometric distribution applies, note that elements of are already fixed, leaving elements of that can be chosen from the set , which has size . Mark the elements in the range ; from these, must be chosen. The remaining items are chosen from the unmarked elements in the set which has size .
From Definition 5.10, the mean of this distribution is
Since , and since , the mean and modes (which differ from the mean by at most 1) are . We denote the larger mode of this distribution by , and so we have
For any and where receives the input pair we know that both and results in receiving the input pair . We will want to show that there is some constant such that for every choice of and ,
Since the hyper-geometric distribution is unimodal, i.e., strictly non-decreasing to , the larger mode, and then strictly non-increasing after that point, for any we immediately have that . Likewise for any we immediately have that .
When shifting small elements from B to A, each old with a value in this interval becomes and each old with a value in this interval becomes .
As an illustrative example of this, consider so and are just the even and odd indices respectively of and when sorted. Fix and . Then and . If we swap values 0 and 7 between and , then we get , and , . We have that and for .
When we give a lower bound on and then use the arithmetic geometric mean equality to deduce that . Using a telescoping product, we have that:
We first show that the telescoping product is well-defined, i.e., that all terms , , are positive. The left binomial term of Eq. (8) for is . From Eq. (7) we have that . Also, and so, since by Eq. (9), we have
Therefore for sufficiently large , since , is positive and less than the upper index, , so the first binomial term, , is positive.
Now consider the right binomial term of Eq. (8) for , which is . We have that , so the upper index of the binomial is at least . Using the expression for above, as well as the fact that , Eq. (6), we can bound the lower index as follows:
which again is positive and is less than the upper index for sufficiently large n.
We now expand the telescoping product above:
In the last line, inside the product there are four terms, each of the form , where, from our previous derivations, and . Therefore for some positive constant , each of these terms is at least . Therefore, since ,
where for the last inequality we use the fact that for all .
Using the arithmetic geometric mean inequality,
where the constant is . We have now proven (10) in all cases, Let denote the number of choices of set such that will receive input . Then:
where the last inequality comes from the fact that this sum is counting each possible at most twice. By symmetry the same argument gives that . Since every equipartition is equally likely we can conclude that:
as desired.
☐
Thermodynamic bounds Now that we have proven Lemma 5.11, we are ready to prove our thermodynamic bounds.
Lemma 5.12. Let D be an ordered set and D be the distribution resulting from picking n elements of D without replacement uniformly at random. Let n be sufficiently large so that Lemma 5.11 applies. Any gate in Batcher's odd-even mergesort where Lemma 5.11 can be applied must release expected heat.
Proof. Assume for now that . By (5) and Lemma 5.11 we know that the optimal heat function for such a gate with induced marginal input distribution is given by . Since this applies to every input pair , the expected heat dissipation is . This lower bound also applies to arbitrary sets due to Lemma 5.5.
Theorem 5.13. Let be an ordered set and be the distribution resulting from picking elements of without replacement uniformly at random. Batcher's odd-even mergesort must release expected heat on input distribution . When using the optimal heat function for each gate, this value is .
Proof. We do this by counting the number of gates where we can apply Lemma 5.12. Let denote the count of such gates in the circuit of size . In the non recursive step, when is sufficiently large, the admissible gates are those in layers that are central. As in the proof of Lemma 5.11, let be the width of gates in layer . There are at least choices of such that . By (4), at least half of these have the correct value of to be either the top or the bottom node of a gate. Of these potential gates, at most of them do not actually exist due to the constraint on the starting point of gates. After all this, the number of gates in layer is at least for sufficiently large . The number of considered layers is . Thus the number of relevant gates in the non recursive step is at least or with the asymptotic upper bound coming from the total number of gates in the non-recursive step. Considering in the recursive step, we have:
Which is by the Master theorem.
By Lemma 5.12, each of these gates must release heat in expectation. Thus the total heat dissipation of the circuit is . To see that this bound is asymptotically tight, observe that the heat function is valid. Since there are total gates in Batcher's odd even mergesort, this choice for gives a total of expected heat released.
Corollary 5.14. Let be an ordered set and be the distribution resulting from picking elements of without replacement uniformly at random. Batcher's odd-even mergesort has circuit entropy production on input distribution .
Proof. By Theorem 5.13 we know this circuit releases expected heat. The drop in entropy by sorting an input is at most which is only . Thus the released heat dominates the drop in entropy term for this circuit.
We have thus shown that Batcher's odd even mergesort network is thermodynamically inefficient.
5.3 A more thermodynamically efficient sorting network
In Section 5.2.2 we showed that Batcher's odd even mergesort is a poor choice if one is interested in optimizing the thermodynamic costs of sorting more than just bits, as the minimal expected heat released is asymptotically larger than the drop in entropy. If one is only interested in asymptotic bounds, then there is a trivial way to get a sorting network with expected heat release by using the AKS sorting network which has only gates [AKS83]. However, this construction has such a large constant hidden in the O notation that it is unsuitable for actual implementation.
A network sorting almost all inputs In [LP98] the authors present a comparator network that sorts almost every permutation of using only comparator gates. We will show how this construction can be leveraged to give a sorting network that releases only expected heat. To start, we cite the relevant result from their paper.
Proposition 5.15 ([LP98]). Let . For every there is a deterministic (non-uniform) network of depth that sorts a uniformly random permutation of with probability at least .
Remark 5.16. In [LP98] the authors actually prove a bound that works for every however, this stronger error bound requires invoking AKS on small subproblems. Thus the enormous constant associated with AKS would still be present in the term in the depth bound. Instead, we use a weaker version of their result that they explicitly mention at the end of section 6 where AKS is replaced by bitonic sort. This slightly weakens the error bounds but avoids the large constant factor in the overall cost.
In addition to a depth bound that is linear in , Proposition 5.15 has only a linear number of gates per layer. Thus the overall gate count is only . We will only need to instantiate this with . The following corollary suffices for our use case.
Corollary 5.17. Let be a power of two, be an arbitrary ordered set and be the distribution over inputs given by sampling elements of uniformly at random without replacement. Then there exists a deterministic (non-uniform) network with gates that correctly sorts inputs except with probability at most .
A sorting network with low expected released heat Now we show that the network in Corollary 5.17 can be used as a subroutine in a thermodynamically efficient sorting network. Intuitively, this network sorts most inputs using only a small number of gates. This allows it to be followed by a larger sorting network which uses a heat function that takes advantage of the fact that its input is often already in sorted order.
Theorem 5.18. Let be an arbitrary ordered set and be the distribution over inputs given by sampling elements of uniformly at random without replacement. There is a thermodynamic sorting network with gates that are each augmented with one of two heat functions such that, on input distribution , the expected heat dissipation of is .
Proof. We fix to be the concatenation of the sorting network in Corollary 5.17 on all wires (call this ) followed by Batcher's odd even mergesort on the same wires (call this ). Since Batcher's odd even mergesort is a sorting network, we know that is also a sorting network. We augment every gate in with the heat function . Since has gates, the expected heat dissipation of this component is also . Importantly, after running , the input is already sorted except with probability at most .
We augment every gate in with the heat function:
The validity of follows from Lemma 2.22. When receives an already sorted input from , this choice of implies that every gate will dissipate only heat. Since has total gates, the expected released heat conditioned on sorting its input is only . Conditioned on failing to sort its input, some gates in the network might release up to
expected heat. Even if every gate releases this much, the expected released heat conditioned on failing to sort its input is only . Thus the total expected heat released by is at most:
as desired. Since both and release only expected heat, so does .
It is important to note that this construction is heavily reliant on the input distribution D. If D gives heavy weight to inputs that fails to sort, then the analysis presented here falls apart.
6 Clean zero entropy circuits for compaction and sorting
We start by considering bit compaction as a special case of sorting with only two possible values for each key. We give a detailed overview of this circuit with zero circuit entropy production and then show how the idea can be extended to more general sorting.
6.1 A clean compaction circuit with zero entropy production
We describe a bit-sorting (a.k.a., bit-compaction) circuit with zero (assuming the distribution of the inputs is exchangeable, explained below). For any binary string , write to denote the number of 1's in and to denote the number of 0's.
First, we note that we are considering compaction circuits, rather than sorting networks: these can use more general gates than the comparators used in Sections 5.2, 5.2.2 and 5.3, and they are allowed ancilla wires beyond those needed to store inputs and outputs. Although the problem of sorting bits with a sorting network as in Section 5.2 is nontrivial due to Proposition 5.1, general circuits can perform compaction without payloads by simply counting the number of times each key appears in the input. Thus, we add payloads that must be sorted alongside their keys to make the problem non-trivial.
This problem was studied by Asharov, Lin, and Shi [ALS21], who gave an sized circuit for compaction (when the keys are sufficiently small) without considering the thermodynamic costs. The input is key-value pairs called records, where is a one-bit key and
See also [LS22]. The problem has a longer history in other models of computation, going back to Pippenger's self-routing superconcentrators [Pip96]. With comparator gates only, compaction is equivalent to sorting: by Proposition 5.1, a comparator network that sorts every 0/1 key vector sorts every input, so comparators are necessary and sufficient [AKS83]. With general Boolean gates, Asharov, Lin, and Shi [ALS21] gave the first compaction circuits of size for m-bit payloads, up to a poly( ) factor that disappears when or for any constant c, but with superpolylogarithmic depth; Koucký and Král [KK21] reduced the depth to with size , and Lin and Shi [LS22] to the optimal with size . (Pippenger's self-routing superconcentrators [Pip96] already give gates [ALS21]; in the RAM model, oblivious compaction takes linear time [AKL 23], but word operations cost gates, so this does not yield linear-size circuits.) All of these circuits are non-stable, necessarily so: stable compaction needs selector gates if payloads are only routed and never computed on [LSX19], and gates in general if the Li-Li network coding conjecture [LL04] holds [AFKL19, ALS21]. To our knowledge it remains open whether the poly( ) factor can be removed for every m, and no unconditional superlinear lower bound is known for stable compaction, or for sorting keys of length , with general gates. The circuits in this paper are much larger than these; they are designed for zero circuit entropy production, not size.
A superconcentrator is a network of 2-input, 2-output switches, with n inputs and n outputs, such that for every
is the payload matrix, whose 'th row , is the -bit payload value in record . The goal is to sort the records by the key; for example sorting , , , could result in sorted order , , , . (There is no requirement that the sort be stable, i.e., preserve the original order between two records with equal keys.) The requirement to carry the payload values along with the keys means that we must really track the order of the records as we sort them; simply counting the 1's as above is not sufficient.
Theorem 6.1 assumes the distribution on the input record list is exchangeable, which means that any permutation of the n record positions gives the same distribution over inputs. This allows payloads to be arbitrarily correlated with their keys but prevents, for example, a bias towards keys that are almost already sorted or payloads that encode the initial indices of their record.
Our circuit is based on first computing the mapping , where represents the unsorted 1-bit keys, represents the associated -bit payloads, is the sorted keys, and is the sorted payload matrix. To make the computation clean, we then erase the bits with zero EP, which requires determining the probability that a bit is 1 and then routing it to an erasure gate optimal for that probability. It turns out that there are many such probabilities, which implies that this technique requires erasure gates. It remains an open question whether one can erase bits, which in total have quadratically many possible distributions, using gates, or to compute the desired mapping with zero circuit entropy production using a different technique to obtain total gates. We note that for any register , both copying and moving can be done reversibly.
The next theorem turns an arbitrary sorting network into a compaction circuit with zero circuit entropy production.
Theorem 6.1. For all positive integers and , for any sorting network with gates and depth , there is a circuit cleanly solving the 1-bit key, -bit payload value, compaction problem on inputs, with for every exchangeable distribution over input record lists, using gates, depth, and ancilla wires.
Proof. Denote the input , where represents the 1-bit keys, and is the payload matrix whose row , is the value associated with key . The correct output of the compaction problem on input is , where represents the compacted keys (assuming there are 1's in ), and represents the associated values, sorted according to the keys. (That is, the final rows are exactly those associated with 1 keys.)
Most of the task of doing compaction with zero circuit entropy production will use standard reversible computing primitives to compute the mapping . The main difficulty is erasing b with zero EP, once the rest of the output is correct and the other input V is reversibly erased. This last erasure of b is the only part of the circuit that is not logically reversible and thus the only part which requires a heat function with non-zero entries. In order to obtain zero circuit entropy production, we must pick these heat functions, per Lemma 3.1, in a way that exactly matches the induced distribution over inputs for each bit being erased. Unfortunately, this induced input distribution depends on values other than the bit being erased (see Appendix D).
k and every choice of k inputs and k outputs, some setting of the switches joins them by k vertex-disjoint paths; self-routing means the network computes that setting itself from flags presented at its inputs, rather than being handed it by an external routing algorithm. A switch differs from a comparator in that it is told whether to swap by a separate control wire and never inspects the payloads it carries, so compaction in this model splits into a control computation over the n keys and a data path moving the m-bit payloads as opaque cargo.
for why this causes positive entropy production). Thus, it is necessary to determine the induced marginal probability distribution over the bit being erased conditioned on the values stored on all other wires to obtain zero circuit entropy production.
First we explain how to compute the mapping reversibly. In the sorting network , replace each comparator gate between wires and with a reversible comparator between records that also outputs (for reversibility) whether a swap occurred:
where the primed values are the identity if and swapped otherwise, with if a swap occurred and 0 otherwise. To implement this record comparator using constant-size gates, we reversibly distribute to clean ancilla wires using a balanced tree of copy gates of depth , use those copies to swap all pairs of payload bits in parallel, and then reverse the copy tree. Thus each comparator of becomes gates of depth . All record comparators belonging to one layer of act on disjoint records, so their copy trees and bit swaps can be performed in parallel. The resulting reversible sorting computation has gate complexity and depth . Running this modified sorting network on the records results in the sorted output described above, along with “garbage” data indicating which swaps occurred, reversibly computing the mapping
We now reversibly copy s:
Now, “uncompute” C via the mirror-image reverse of the first sorting step, but using swap gates that only swap the keys, leaving the sorted payloads in place:
This completes the mapping , using gates and depth.
At this point we almost have the clean output , but it remains to erase the unsorted key bits b.
Write to denote the 'th prefix of (similarly , , and ). Let . We erase the bits one at a time starting with the first, successively producing . Suppose we currently have and now need to erase ; call this stage . The correct distribution to assume when erasing when we apply Lemma 3.1 is such that the probability of a one is ; we justify this at the end of the proof. The denominator is a fixed constant in stage of this circuit, so the key is to make the numerator reversibly available in a binary register , which will then be used to route to a “controlled erasure” gate with an optimal heat function for this probability. We explain below how to maintain incrementally as we iterate through the bits of .
A controlled erasure gate takes two input bits: c and b. If the control bit c = 0, then it leaves b alone (and releases 0 heat), otherwise it erases b. We need these because there will be a “bank” of several that might be used, but only one will actually be used to erase , i.e., will have its c = 1; the other gates will have c = 0.
An example of the erasure subcircuit for stage is shown in Figure 5. There are pairs of clean wires, one pair for each possible numerator . Set a clean wire to 1 with a NOT gate and, using a reversible -way demultiplexer, route the pair (the first bit is a control bit for the controlled erasure gate downstream) to output wires addressed by the binary value in register . Thus the selected pair contains and every other pair contains . On pair , apply a controlled erasure gate to each such pair for , using a heat function optimal for probability . Consequently only the selected gate performs an erasure, using the heat function optimal for the probability ; all other gates act reversibly with zero heat since their control bits are 0. After these gates act in parallel, reverse the demultiplexer (a.k.a., multiplexing) using the same address . It returns the pair , after which a NOT gate restores the control wire to 0, while the original wire and all routing wires are also 0.

Figure 5: The subcircuit for erasing bit when , so and the gate must assume . Reversible demultiplexer drawn without extra clean input wires needed to supply 0's to unaddressed output wires, and similarly for unshown output wires of multiplexer that simply pass through unaddressed inputs.
A binary-tree demultiplexer uses constant-size gates and depth. Together with the controlled erasure gates, stage i therefore uses gates and depth for routing and erasure.
Computing from scratch with a straightforward sequential implementation would require depth, and since this must be done sequentially for each bit erasure, the total depth would be if computed naïvely. Instead, we observe that can be updated incrementally using only depth as we erase bits. Maintain a register , initially 0. Just before stage , maintain the invariant that , the number of 1's among the already-erased prefix bits. At stage , do the reversible increment to update to represent . This requires only depth per bit erasure (using a standard ripple-carry increment), so total depth for all bit erasures. After the final erasure, . To restore this
A demultiplexer takes as input a value v (one or more bits), and an address a interpreted as a binary integer, and routes v to one of several output lines based on the value of a.
The increment must precede the demultiplexing that selects the erasure gate. If the pre-increment value were used as the address instead, then , , and would together determine , since is determined by the first two. Erasing would then destroy the mutual information between and the rest of the circuit, which by Proposition D.1 produces entropy no matter which heat function the erasure gate uses. After the increment, carries no information about beyond what and already determine.
We could actually do better than depth to increment Z, using depth by using a parallel prefix circuit [LF80]. However, we forsake such optimizations, since we are already using depth for the work register to 0, as required for clean output, apply for each in turn the reversible decrement , the inverse of the increment above, with the retained sorted key bit as the control. Since starts at , ends at 0. This uses decrements of gates and depth per bit, i.e., gates and depth total.
The erasure portion uses controlled erasure gates, one for each possible numerator at each stage ; the forward and reverse demultiplexers use additional reversible gates in total. Together with the reversible sorting computation, the total gate complexity is (for the sorting network) plus , i.e., . The depth is since we have layers of single-bit erasure, one for each , and each layer requires depth as justified above (plus the depth of the reversible sorting computation.) The circuit uses wires beyond the input wires: for the register that receives ; for the garbage bits ; for the copy trees of the comparators in one layer of , which are returned to 0 after each layer and reused by the next; and for the register , the demultiplexers, and the pairs of wires feeding the controlled erasure gates, which are likewise returned to 0 after each stage and reused by the next.
Now we show that this gives us zero circuit entropy production. Overall, we are mapping to .
Since is a deterministic function, we have that . Since is exchangeable, is irrelevant to the conditional probability distribution, so this equals . Since is exchangeable, each with a fixed value of is equally likely, so and the total drop in entropy is:
We will now show that our choices of heat function for erasing each bit of any fixed with result in the circuit releasing exactly this much heat in expectation. We now fix and any such that . As a reminder, we are picking the optimal heat function per Lemma 3.1 for erasing bit based on the probability that is 1 is . This gives us the heat function
for erasing the 'th bit of . Let denote the indices of where and denote the indices of where . Then the expected heat released on input is exactly
demultiplexer used to route the bits to erase, so there is no asymptotic benefit in optimizing the increment depth. In fact, given our setup, there is no way to demultiplex in depth, since we need a single value to reach one of different wires, but due to size gates, each layer only enables it to reach a constant multiple more wires than the previous. This does not rule out a more sophisticated approach that can achieve amortized depth per bit erasure, using some sort of “pipelining” for instance, or perhaps some way to erase bits in parallel.
The distribution over payloads must be independent of their input index and b is a permutation of s.
Due to the linearity of expectation, the total expected heat released during compaction is exactly
Since the drop in entropy (11) and the expected heat release (12) are identical, we can conclude that .
Remark 6.2. The analysis in Theorem 6.1 has a natural extension to compaction on k-bit keys by instead applying Lemma 3.1 to pick heat functions where, for every , the chosen distribution over inputs has where denotes the count of key in .
6.2 A clean sorting circuit with zero entropy production
Our method of zero circuit entropy production erasure in Section 6.1 can be extended to give a circuit with zero entropy production for sorting. As we are now doing general sorting, we can always assume that payloads are just low order bits of the keys and therefore ignore them altogether. Thus the task is now, given an input with each , output where the are a permutation of the such that, for every , . For simplicity, we will assume that our larger keys can be compared with a single comparator gate, which is implemented using multiple constant-arity gates.
Theorem 6.3. Let D be any exchangeable distribution over ^n. There exists a polynomial sized (in terms of n and m) circuit that sorts n inputs that are each m bits with zero circuit entropy production.
Proof. We will use the same circuit as in Section 6.1 to map input to the state using only logically reversible gates. Now, the task is to erase the copy of with zero circuit entropy production. For , and , we use to denote the number of such that .
We will erase the highest order bit of every before moving on to the next highest order bit and so on. In other words, the order in which we erase bits will be . Let denote the 'th bit of . Analogous to before, we now use to denote the suffixes starting on the 'th bit of for all . When erasing , we will use the optimal heat function, per Lemma 3.1, for the distribution with:
where denotes the suffix of beginning with index with a 1 appended to the front. In other words, the probability of a 1 is exactly the probability one would get a 1 by sampling uniformly at random the 'th bit of any with that shares its suffix after index with . While it would be unfeasible to track these counts for every possible suffix, this probability can be computed on the fly for each erasure by paying a polynomial cost in the depth of the circuit and the number of gates. This follows from the fact that these counts can be computed (and uncomputed) in a logically reversible fashion even after the actual value of has been erased. We will use the same reversible demultiplexer / multiplexer gadget as in the compaction circuit with controlled erasure gates to selectively pick the optimal heat function to use for each erasure.
Now we argue that this approach gives us a circuit with zero circuit entropy production. First we consider the drop in entropy from the mapping . Let be the vector of counts for the number of times each possible appears in the input . Then we have that and thus when :
(13)
Note that this term only has support on where the 1-norm (i.e. Manhattan norm) of is exactly .
As before, we will now show that our choices of heat functions for erasing each bit release expected heat on every input with count vector . Our heat function for erasing the 'th bit of the 'th input will take the form:
Let's fix any and let . Then the total expected heat released on input is exactly
The counts of 0's versus 1's for erased prefixes can be deduced from the sorted output and the non erased part of the input. For example, and the terms on the right can be computed after has been erased. Control gates can be used to ensure that we only count the number of 0's and 1's for inputs with the desired suffix.
Due to the linearity of expectation, the total expected heat released during sorting is exactly:
Since the drop in entropy (13) exactly matches the expected heat released (14) by our circuit, we can conclude that the circuit entropy production is zero.
7 Conclusion
In this paper we posit that the concepts of entropy production and heat release provide a principled foundation for understanding inherent energy costs of computations. We introduce a thermodynamic logic circuit model in which gates (e.g., Boolean logic gates or comparator gates) are augmented with heat functions, which determine a circuit's entropy flow and entropy production with respect to a given input distribution. We show that in general, determining optimal heat functions is computationally intractable. In contrast, we show that for specific problems (i.e. sorting) our model can be used both to analyze the thermodynamic costs of existing circuits and to design new circuits that are thermodynamically efficient.
There are many directions for future work. Our analysis of Batcher's odd-even mergesort on bits uses a set of gate heat functions that scales with the circuit size; what are the penalties for using only a constant number of distinct heat functions for this problem? How can we analyze heat dissipation of circuits in other problem domains, such as graph algorithms? What are good general design principles for energy-efficient computation?
Theorem 6.1 shows a zero EP circuit for bit-compaction, the problem of sorting 1-bit keys with m-bit payloads, using depth (as long as is ). Can we design a zero EP compaction circuit with polylog(n) depth? This rules out erasing key bits one at a time as we do, which requires depth. Is it possible to show a lower bound of depth for the clean compaction problem, arguing that zero EP erasure with constant arity gates must do so sequentially?
Another limitation of our technique to do compaction in Theorem 6.1 is that we require erasure gates. This is necessary given our specific erasure technique: we get the circuit to a point where it has the intended output (compacted key-payload records), as well as the uncompacted keys , and we erase each key bit one at a time. There are conditional probabilities that are possible for each bit to be a 1 across all stages during this process, necessitating erasure gates. However, this does not rule out a more sophisticated way to erase the bits in which we do not encounter so many different conditional probabilities. Perhaps some efficient reversible circuit computation could be done on to transform it into a different bit string of length , such that while erasing the bits of in order, each bit would only have one of, say, different (possibly position-dependent) probabilities. In this case total erasure gates would suffice to erase all bits.
Suppose the number of erasure gates could be reduced to , or if so that the erasure gates are negligible. (To simplify discussion below assume , so that
It is even worse for our circuit, , due to requiring depth per bit to route it through a -layer demultiplexer to the erasure gate with appropriate heat function.
swapping m-bit payloads takes gates in our model.) Then it becomes more important to reduce the size of the compaction/sorting circuit implementing the underlying routing logic in Theorems 6.1 and 6.3. For instance, Theorem 6.1 can very likely be improved to use the -gate compaction circuit of Asharov, Lin, and Shi [ALS21], instead of a sorting network that requires gates by the 0/1 principle.
Rather than insisting on , one can ask for the minimum achievable by compaction circuits of near-linear size or polylogarithmic depth. We know of no lower bound of the form “depth forces ” for any ; such a bound would be the first general quantitative trade-off between a standard circuit resource and entropy production.
Theorem 6.1 uses a single circuit, with finitely many heat functions, that has zero EP for every exchangeable input distribution simultaneously, because the conditional probability that each erased bit is 1 depends only on exchangeability. For which other classes of distributions is this possible? If, for instance, the keys are independent but position-dependent, the conditional probabilities depend on the bias of every position, and it is unclear whether finitely many heat functions suffice. Conversely, what is the EP of our circuit when the input is only approximately exchangeable, say as a function of a divergence between the actual distribution and the nearest exchangeable one?
Analogous questions about the gate and depth complexity for zero circuit entropy production sorting are natural. In general, a more detailed study of gate-depth-entropy tradeoffs for sorting is worthy of further investigation.
Our results concern expected EP and expected heat. What are the variance, and the worst case over inputs, of the heat released by our circuits, and is there a trade-off between the fluctuations of heat and circuit size or depth, in the spirit of the thermodynamic uncertainty relations of stochastic thermodynamics [HG20]? Can we obtain concentration guarantees on the distribution of expected heat and entropy production?
Section 5.2 shows that Batcher’s network has on uniformly random bits and on uniformly random distinct inputs, and Section 5.3 gives a network releasing only expected heat, but, as noted in Section 5.2, it is open whether every sorting network has , or even , on uniformly random bits. (Every sorting network must release heat, since that is the Landauer cost of sorting bits; zero means releasing exactly that much.) A positive lower bound would show that comparators alone cannot achieve zero , so that the more general gates of Theorem 6.1 are necessary. In the other direction, Theorem 6.1 uses ancilla wires, where is the size of the underlying sorting network. What is the minimum number of ancilla wires in a zero sorting or compaction circuit? In particular, can zero be achieved in place, with no ancilla wires, using -size gates more general than comparators?
Our thermodynamic circuit model is deterministic; we are interested in adapting it to circuits with probabilistic gates, where the output of a gate on a given input is specified as a distribution over the possibilities. We also would like to understand heat dissipation in other models of computation, such
Our main reason for using sorting networks is that it is more straightforward to transform them to be reversible in a black-box way, whereas more sorting circuits allowing more general gates than comparators require more complex hypotheses about how the sorting circuit treats its keys and payloads. For example it is important for our technique that routing decisions are made based only on keys, never payloads, which is true of the networks of Asharov, Lin, and Shi [ALS21] and Lin and Shi [LS22].
Ancilla wires alone would not help a comparator network on bits: a comparator between a data wire and a wire holding a known constant is a data-independent wire crossing (with constant 0 it maps , and with constant 1 it maps ), which is a bijection on its reachable inputs, so it can be assigned zero heat and removed by renaming wires, without changing the outputs or increasing EP.
as random access machines. Can we show trade-offs between time, space, and entropy production? Might it be possible to show average-case hardness results for heat dissipation?
8 Acknowledgments
Niels Kornerup's contribution to work was supported by the Laboratory Directed Research and Development program (project 240650) at Sandia National Laboratories, a multimission laboratory managed and operated by National Technology and Engineering Solutions of Sandia LLC, a wholly owned subsidiary of Honeywell International Inc. for the U.S. Department of Energy's National Nuclear Security Administration under contract DE- NA0003525. This paper describes objective technical results and analysis. Any subjective views or opinions that might be expressed in the paper do not necessarily represent the views of the U.S. Department of Energy or the United States Government. The publisher acknowledges that the U.S. Government retains a non-exclusive, paid-up, irrevocable, world-wide license to publish or reproduce the published form of this written work or allow others to do so, for U.S. Government purposes. The DOE will provide public access to results of federally sponsored research in accordance with the DOE Public Access Plan.
David Wolpert thanks the Santa Fe Institute for their support.
8.1 Discussion of substantive LLM use
In Section 4.2, we used ChatGPT 5.6 to help us strengthen Lemma 4.7 to inputs where it is promised that . In particular, the LLM pointed us towards Lemma 4.6 as a black-box way to convert any SAT instance into a new one where (1) there is always some satisfying assignment and (2) there is a programmable gap between the number of satisfying assignments for depending on whether or not had some satisfying assignment. We uncovered that the LLM likely arrived at this exact construction based on a similar construction by Blass and Gurevich [BG82] designed to handle (1) and then observing that (2) follows directly from adding additional dummy variables. The LLM also generated a full proof of Lemma 4.7 which we have heavily simplified into the version presented in this paper.
We suspected that the add-one smoothing estimator would be a natural candidate to use in the proof of Lemma 4.8, as it is a simple estimator which avoids the catastrophic pitfall of assigning zero probability on any event with positive probability, and asked the LLM to show that this estimator gives our polynomial time additive approximation. The LLM observed that the excess heat dissipation associated with using an estimator is upper-bounded by the expected KL-divergence between the input distribution and its estimated version. We identified that this is an immediate consequence of what is now known as mismatch costs that were first identified by Kolchinsky and Wolpert [KW17]. Next, the LLM proceeded to give a rather convoluted proof that upper bounds the expected KL-divergence between an input distribution and its add-one smoothed estimator. We instead identified that Braess, Forster, Sauer, and Simon [BFSS02] directly proved that the add-one smoothing estimator is well suited for minimizing the expected KL-divergence.
We independently discovered proofs of Lemma 5.12 and Theorem 5.13 where the heat function was restricted to only depend on the value of the comparison (i.e. is ?) rather than the actual input values. The LLM helped us find that shifting exactly small elements between sets A and B causes a central gate to receive input , instead of input , , which was the key ingredient in our proof of Lemma 5.11, that let us extend our lower bound to general heat functions.
The high level strategy in Section 5.3 of combining an gate almost sorting network with an gate network to reduce the expected heat dissipation was the result of interactions between the authors and the LLM when searching for a more thermodynamically efficient sorting network on integers than Batcher's.
ChatGPT 5.6 and ChatGPT 6 Astra were used to help proofread this document and catch basic errors, which were fixed by the authors. Fig. 4 was generated by code produced with the assistance of Claude code. All text, proofs, and the remaining figures in this paper were produced by the authors, who take full responsibility for the correctness and originality of all content therein.
References
[AB09] Sanjeev Arora and Boaz Barak. Computational complexity: A modern approach, volume 1. Cambridge University Press Cambridge, 2009.
[AFK 98] M. Josephine Ammer, Michael Frank, Tom Knight, Nicole Love, Norman Margolus, and Carlin Vieri. A scalable reversible computer in silicon. In Unconventional Models of Computation, pages 183–200. Springer-Verlag, 1998.
[AFKL19] Peyman Afshani, Casper Benjamin Freksen, Lior Kamma, and Kasper Green Larsen. Lower bounds for multiplication via network coding. In 46th International Colloquium on Automata, Languages, and Programming (ICALP 2019), volume 132 of LIPIcs, pages 10:1–10:12, 2019.
[AKL 23] Gilad Asharov, Ilan Komargodski, Wei-Kai Lin, Kartik Nayak, Enoch Peserico, and Elaine Shi. OptORAMa: Optimal oblivious RAM. Journal of the ACM, 70(1):4:1–4:70, 2023.
[AKS83] Miklós Ajtai, János Komlós, and Endre Szemerédi. An sorting network. In David S. Johnson, Ronald Fagin, Michael L. Fredman, David Harel, Richard M. Karp, Nancy A. Lynch, Christos H. Papadimitriou, Ronald L. Rivest, Walter L. Ruzzo, and Joel I. Seiferas, editors, Proceedings of the 15th Annual ACM Symposium on Theory of Computing, 25-27 April, 1983, Boston, Massachusetts, USA, pages 1–9. ACM, 1983.
[ALS21] Gilad Asharov, Wei-Kai Lin, and Elaine Shi. Sorting short keys in circuits of size . In Proceedings of the 2021 ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 2249–2268. SIAM, 2021.
[AW22] Shyan Akmal and Ryan Williams. MAJORITY-3SAT (and related problems) in polynomial time. In FOCS 2021: Proceedings of the 62nd IEEE Annual Symposium on Foundations of Computer Science, pages 1033–1043. IEEE, 2022.
[Bat68] K. E. Batcher. Sorting networks and their applications. In Proceedings of the April 30–May 2, 1968, Spring Joint Computer Conference, AFIPS '68 (Spring), page 307–314, New York, NY, USA, 1968. Association for Computing Machinery.
[Ben73] Charles H. Bennett. Logical reversibility of computation. IBM Journal of Research and Development, 17(6):525–532, November 1973.
[Ben82] Charles H. Bennett. The thermodynamics of computation—a review. International Journal of Theoretical Physics, 21(12):905–940, 1982.
[Ben89] Charles H. Bennett. Time/space trade-offs for reversible computation. SIAM Journal on Computing, 18(4):766–776, 1989.
[BFSS02] Dietrich Braess, Jürgen Forster, Tomas Sauer, and Hans Ulrich Simon. How to achieve minimax expected kullback-leibler distance from an unknown finite distribution. In Nicolò Cesa-Bianchi, Masayuki Numao, and Rüdiger Reischuk, editors, Algorithmic Learning Theory, 13th International Conference, ALT 2002, Lübeck, Germany, November 24-26, 2002, Proceedings, volume 2533 of Lecture Notes in Computer Science, pages 380–394. Springer, 2002.
[BG82] Andreas Blass and Yuri Gurevich. On the unique satisfiability problem. Inf. Control., 55(1-3):80–88, 1982.
[BJO21] Rory A. Brittain, Nick S. Jones, and Thomas E. Ouldridge. What would it take to build a thermodynamically reversible universal turing machine? computational and thermodynamic constraints in a molecular design, 2021.
[BTV01] Harry Buhrman, John Tromp, and Paul M. B. Vitányi. Time and space bounds for reversible simulation. Journal of Physics A: Mathematical and General, 34(35):6821–6830, 2001.
[CT06] Thomas M. Cover and Joy A. Thomas. Elements of information theory (2. ed.). Wiley, 2006.
[DKL 24] David Doty, Niels Kornerup, Austin Luchsinger, Leo Orshansky, David Soloveichik, and Damien Woods. Harvesting Brownian motion: Zero energy computational sampling. arXiv:2309.06957, 2024.
[DLMT16] Erik D. Demaine, Jayson Lynch, Geronimo J. Mirano, and Nirvan Tyagi. Energy-efficient algorithms. In Proceedings of the 7th Annual ACM Conference on Innovations in Theoretical Computer Science (ITCS 2016), pages 321–332. ACM, 2016.
[FA17] Michael P. Frank and M. Josephine Ammer. Relativized separation of reversible and irreversible space-time complexity classes. CoRR, abs/1708.08480, 2017.
[FBT 20] Michael P. Frank, Robert W. Brocato, Brian D. Tierney, Nancy A. Missert, and Alexander H. Hsia. Reversible computing with fast, fully static, fully adiabatic CMOS. In International Conference on Rebooting Computing, ICRC 2020, Atlanta, GA, USA, December 1-3, 2020, pages 1–8. IEEE, 2020.
[Fra02] Michael P. Frank. The physical limits of computing. Comput. Sci. Eng., 4(3):16–26, 2002.
[Fra17] Michael P Frank. Foundations of generalized reversible computing. In International Conference on Reversible Computation, pages 19–34. Springer, 2017.
[Fra18] Michael P. Frank. Physical foundations of landauer's principle. In Jarkko Kari and Irek Ulidowski, editors, Reversible Computation - 10th International Conference, RC 2018, Leicester, UK, September 12-14, 2018, Proceedings, volume 11106 of Lecture Notes in Computer Science, pages 3–33. Springer, 2018.
[FT82] Edward Fredkin and Tommaso Toffoli. Conservative logic. International Journal of Theoretical Physics, 21(3–4):219–253, 1982.
[Gil74] John T. Gill. Computational complexity of probabilistic Turing machines. In Proceedings of the 6th Annual ACM Symposium on Theory of Computing, STOC '74, pages 91–95. Association for Computing Machinery, 1974.
[HG20] Jordan M. Horowitz and Todd R. Gingrich. Thermodynamic uncertainty relations constrain non-equilibrium fluctuations. Nature Physics, 16(1):15–20, 2020.
[HM18] Ralf Hinze and Clare Martin. Batcher's odd-even merging network revealed. J. Funct. Program., 28:e14, 2018.
[Hoe63] Wassily Hoeffding. Probability inequalities for sums of bounded random variables. Journal of the American statistical association, 58(301):13–30, 1963.
[Int26] International Energy Agency. Key questions on energy and AI. Technical report, International Energy Agency, Paris, 2026. Licensed under CC BY 4.0.
[KK21] Michal Koucký and Karel Král. Sorting short integers. In 48th International Colloquium on Automata, Languages, and Programming (ICALP 2021), volume 198 of LIPIcs, pages 88:1–88:17, 2021.
[KMPA14] Jonne V. Koski, Ville F. Maisi, Jukka P. Pekola, and Dmitri V. Averin. Experimental realization of a szilard engine with a single electron. Proceedings of the National Academy of Sciences, 111(38):13786–13789, 2014.
[Knu98] Donald E. Knuth. The Art of Computer Programming, Volume 3: Sorting and Searching. Addison-Wesley, 2nd edition, 1998.
[Kor25] Niels Kornerup. Time, Space, and Energy in Computation. PhD thesis, The University of Texas at Austin, 2025.
[KW17] Artemy Kolchinsky and David H Wolpert. Dependence of dissipation on the initial distribution over states. Journal of Statistical Mechanics: Theory and Experiment, 2017(8), August 2017.
[Lan61] R. Landauer. Irreversibility and heat generation in the computing process. IBM Journal of Research and Development, 5(3):183–191, July 1961.
[LF80] Richard E Ladner and Michael J Fischer. Parallel prefix computation. Journal of the ACM (JACM), 27(4):831–838, 1980.
[LL04] Zongpeng Li and Baochun Li. Network coding: The case of multiple unicast sessions. In Proceedings of the 42nd Annual Allerton Conference on Communication, Control, and Computing, 2004.
[LMT00] Klaus-Jörn Lange, Pierre McKenzie, and Alain Tapp. Reversible space equals deterministic space. Journal of Computer and System Sciences, 60(2):354–367, 2000.
[LP98] Frank Thomson Leighton and C. Greg Plaxton. Hypercubic sorting networks. SIAM J. Comput., 27(1):1–47, 1998.
[LS90] Robert Y. Levine and Alan T. Sherman. A note on Bennett's time-space tradeoff for reversible computation. SIAM Journal on Computing, 19(4):673–677, 1990.
[LS22] Wei-Kai Lin and Elaine Shi. Optimal sorting circuits for short keys. In SODA 2022: Proceedings of the 2022 Annual ACM-SIAM Symposium on Discrete Algorithms, pages 3583–3629. SIAM, 2022.
[LSX19] Wei-Kai Lin, Elaine Shi, and Tiancheng Xie. Can we overcome the n log n barrier for oblivious sorting? In Proceedings of the Thirtieth Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 2419–2438, 2019.
[LTV98] Ming Li, John Tromp, and Paul M. B. Vitányi. Reversible simulation of irreversible computation. Physica D: Nonlinear Phenomena, 120(1–2):168–176, 1998.
[LV96] Ming Li and Paul M. B. Vitányi. Reversibility and adiabatic computation: Trading time and space for energy. Proceedings of the Royal Society of London. Series A: Mathematical, Physical and Engineering Sciences, 452(1947):769–789, 1996.
[Mor08] Kenichi Morita. Reversible computing and cellular automata—a survey. Theoretical Computer Science, 395(1):101–131, 2008.
[Nor13] John D Norton. Brownian computation is thermodynamically irreversible. Foundations of Physics, 43:1384–1410, October 2013.
[Pip96] Nicholas Pippenger. Self-routing superconcentrators. Journal of Computer and System Sciences, 52(1):53–60, 1996.
[PP21] Luca Peliti and Simone Pigolotti. Stochastic Thermodynamics: An Introduction. Princeton University Press, 2021.
[Sag14] Takahiro Sagawa. Thermodynamic and logical reversibilities revisited. Journal of Statistical Mechanics: Theory and Experiment, 2014(3), March 2014.
[SCSB15a] Philipp Strasberg, Javier Cerrillo, Gernot Schaller, and Tobias Brandes. Thermodynamics of stochastic turing machines. Physical Review E, 92(4), October 2015.
[SCSB15b] Philipp Strasberg, Javier Cerrillo, Gernot Schaller, and Tobias Brandes. Thermodynamics of stochastic turing machines. Phys. Rev. E, 92:042104, Oct 2015.
[Sei05] Udo Seifert. Entropy production along a stochastic trajectory and an integral fluctuation theorem. Physical Review Letters, 95(4):040602, 2005.
[Sei12] Udo Seifert. Stochastic thermodynamics, fluctuation theorems and molecular machines. Reports on Progress in Physics, 75(12):126001, 2012.
[Sei25] Udo Seifert. Stochastic Thermodynamics. Cambridge University Press, 2025.
[SFS18] Naoto Shiraishi, Ken Funo, and Keiji Saito. Speed limit for classical stochastic processes. Phys. Rev. Lett., 121:070601, Aug 2018.
[Szi29] L. Szilard. über die entropieverminderung in einem thermodynamischen system bei eingriffen intelligenter wesen. Zeitschrift für Physik, 53(11):840–856, 1929.
[Tof77] Tommaso Toffoli. Computation and construction universality of reversible cellular automata. Journal of Computer and System Sciences, 15(2):213–231, 1977.
[Tof80] Tommaso Toffoli. Reversible computing. In Jaco W. de Bakker and Jan van Leeuwen, editors, ICALP 1980: International Colloquium on Automata, Languages and Programming, volume 85 of Lecture Notes in Computer Science, pages 632–644. Springer, 1980.
[Tur09] Sadi Turgut. Relations between entropies produced in nondeterministic thermodynamic processes. Physical Review E—Statistical, Nonlinear, and Soft Matter Physics, 79(4):041102, 2009.
[VdBE15] Christian Van den Broeck and Massimiliano Esposito. Ensemble and trajectory thermodynamics: A brief introduction. Physica A: Statistical Mechanics and its Applications, 418:6–16, 2015.
[Vit05] Paul M. B. Vitányi. Time, space, and energy in reversible computing. In Proceedings of the 2nd Conference on Computing Frontiers, pages 435–444. ACM, 2005.
[WK20] David H Wolpert and Artemy Kolchinsky. Thermodynamics of computing with circuits. New Journal of Physics, 22(6), June 2020.
[WKL 24] David H. Wolpert, Jan Korbel, Christopher W. Lynn, Farita Tasnim, Joshua A. Grochow, Gülce Kardes, James B. Aimone, Vijay Balasubramanian, Eric De Giuli, David Doty, Nahuel Freitas, Matteo Marsili, Thomas E. Ouldridge, Andréa W. Richa, Paul Riechers, Édgar Roldán, Brenda Rubenstein, Zoltan Toroczkai, and Joseph Paradiso. Is stochastic thermodynamics the key to understanding the energy costs of computation? Proceedings of the National Academy of Sciences, 121(45), 2024.
[Wol19a] David H Wolpert. The stochastic thermodynamics of computation. Journal of Physics A: Mathematical and Theoretical, 52(19), 2019. See https://arxiv.org/abs/1905.05669 for a more recent version.
[Wol19b] David H Wolpert. Uncertainty relations and fluctuation theorems for Bayes nets. arXiv preprint arXiv:1911.02700, 2019.
[YCW26] Abhishek Yadav, Francesco Caravelli, and David Wolpert. Entropy production bounds for systems running computer programs, 2026.
[YYW26] Abhishek Yadav, Mahran Yousef, and David Wolpert. A strictly positive lower bound on the thermodynamic cost of running a Boolean circuit, 2026.
[Zhu24] Jihai Zhu. Realizability of heat released in nondeterministic processes derived from a fluctuation theorem. arXiv:2311.16269, 2024.
A Basic lemmas
Lemma 2.12. Let be a function. For any set where is defined, it is the unique choice that minimizes over all distributions supported on .
Proof. Observe that
By Proposition 2.10, we know that and hence is minimized exactly when for every .
Lemma 2.22. Let be a gate in a circuit computing a function . A heat function is valid for if and only if, for every ,
Proof. By Definition 2.21 we know that Q is valid precisely when
Or equivalently when
By convexity, we can assume without loss of generality that the maximum has for some fixed choice of . We can also assume that the maximum has no probability mass on any where unless is on every point and the validity condition is trivial. Additionally, by Lemma 2.12 we know that the maximal is . Thus the above is equivalent to the claim
Taking 2 to the power of both sides of this inequality proves our desired bound.
B Analyzing entropy flow in Batcher's sorting network: overwriting model with binary inputs
Here we show that in the overwriting model, the expected heat dissipation of Batcher's sorting network is , matching our bound for our thermodynamic circuit model. We first describe useful heat functions for our analysis, then use these to bound the expected heat dissipation for layers 1 through of Batcher's network, and finish with a recurrence to bound the total heat dissipation. This proof is very similar to the one for our standard circuit model (i.e. Theorem 5.2).
The overwriting model and its heat functions In the overwriting model, we view a circuit as a DAG where every node represents a gate and edges indicate input dependence. Unlike in our standard circuit model, the gates in the overwriting model retain their output values in a persistent storage between runs and are not required to erase their inputs. As such, the old output to every gate must be overwritten by a new value during each run of the circuit. For this section, we will be assuming that inputs to our overwriting circuit are independently and identically distributed and will use to denote heat functions for circuits in the overwriting model. If a gate in the overwriting model computes a function , then it is actually computing the function for every . As such, the possible heat functions for this gate is given by functions and the validity criteria matches that of Definition 2.21 when the function being computed is .
Since our inputs are independently and identically distributed, there is a significantly simpler expression for the optimal heat function given by Lemma 3.1. Let be the marginal induced distribution over inputs to our gate (including the output from the previous run), be the marginal distribution over new input , and be the marginal distribution over the old output . Then, since is independently and identically distribution, we have that . Thus the optimal heat function for our gate is given by:
So the optimal heat function for gates run on independently identically distributed inputs in the overwriting model is equivalent to the optimal heat function for erasing the value of . Thus we will be specifying heat functions in the overwriting model whose only inputs are the values that are about to be overwritten.
Batcher's odd-even mergesort on bits Rather than use the optimal heat function for every gate, in our analysis, we'll use the three heat functions (parameterized by ) shown in the following table:
| Pr | Pr | Pr | |||||
|---|---|---|---|---|---|---|---|
| 0,0 | 0,0 | ||||||
| 0,1 or 1,0 | 0,1 | ||||||
| 1,1 | 1,1 |
In the table, preceding the column for each heat function , are the probabilities for which that function is optimal. For example. is optimal when with probability ,
(0,1) with probability , and (1,1) with probability (or equivalently when with probability , or with probability , and with probability ). The expected heat release of a gate with one of these heat functions, when the input distribution is optimal, is
using the fact that by application of Taylor's expansion of . Moreover, on distributions where with probability at least , the expected heat release of a gate with heat function is .
We will also use heat function that is optimal on the uniform input distribution. Its values are , and and the expected heat release is
Moreover, for any input distribution, the expected heat release with respect to is at most 2; it approaches 2 as the probability of inputs or approaches 0.
A key difference between the overwriting model and our circuit model is that logically reversible operations do not buy you anything extra in the overwriting model. In Section 5.2 we saw that we could always set since these inputs give unique outputs. On the other hand, we need to dissipate heat when we write over these outputs in the overwriting model.
As in the analysis of Batcher's network for our model, we partition the comparator gates into layers, with layer 0 encompassing the recursive sub-networks, as in Figure 2. Within each layer , we will partition the gates into the same three regions as in the proof of Theorem 5.2, but will pick heat functions that are amenable to the overwriting model. Again is a parameter we will specify later.
Layer 1 In this layer, there are n/2 comparator gates. The i'th gate has input wires i and .
- Upper region: . Since just after layer 0, bits are sorted, and also the remaining bits are independently sorted, it follows from Proposition 2.14 that for in this region,
Consequently, the ith comparator gate has the input with probability at least . If the gate has heat function , the expected heat release is .
-
Lower region: . A similar analysis shows that the ith comparator gate in this region gets as input with probability at least . If the gate has heat function , the expected heat release is .
-
Middle band: . The expected heat release each gate in this region is at most 2 if the gates have heat function .
Summing up over all three regions, the total expected heat dissipation for layer 1 is dominated by the middle band, and is , using three different types of heat functions.
Layer 2 There are n/4 comparator gates in layer 2; we number them by the index of their upper wire, from n/4 to n/2 - 1. The i'th gate has input wires i and . We partition the gates into three regions: a narrow band of gates at the top, a large middle region, and a narrow band at the bottom.
- Top narrow band: . Using the heat function , the expected heat dissipation for each gate is at most 2.
• Middle region: . It follows from Proposition 2.14 that , and . So each comparator gate in this range has input with probability at least . Using the heat function , the expected heat release of each gate is .
- Bottom narrow band: . Using the heat function , the expected heat dissipation for each gate is at most 2.
Therefore, the total expected heat dissipation for layer 2 is dominated by the narrow bands, and is , using two different types of heat functions.
Layers 3 and beyond We will reuse Claim 5.3 from the proof of Theorem 5.2 which shows that with high probability, the number of 1-valued wires in the range , and the number of 0-valued wires in the range , is small.
Claim 5.3. Let . Except with probability , the following hold for every :
-
The number of i such that and is at most .
-
The number of i such that and is at most .
We partition gates of each layer , into three groups: upper gates, lower gates, and crossover gates, defined in the cases below. In Figure 2, where , when there are two upper gates, two lower gates, and two crossover gates.
- Upper gates: Both inputs are from wires in the range . We assign them the heat function . On input , such gates have expected heat dissipation , and otherwise they have expected heat dissipation . It follows from Claim 5.3 that with probability , the number of upper gates that don't have input is . In this scenario, the total (conditional) expected heat dissipation of the upper gates of layer 3 is
With the remaining probability , there may be more gates that don't have input ; in the worst case none of the gates has input . In this alternative scenario the conditional expected heat dissipation is . Taking the expectation over the two scenarios, the total heat dissipation for the upper gates of layer 3 is
• Lower gates: Both inputs are from wires in the range . The reasoning is similar to that for the upper gates, with heat function and expected heat dissipation .
- Crossover gates: One input wire is in the range and the other is in the range . The reasoning is similar to the previous two cases, with heat function and expected heat dissipation .
Summing up over upper, lower and crossover gates, the total heat dissipation per layer in the range 3 to is , and three different heat functions are used.
Theorem B.1. With respect to the overwriting circuit model, when given the uniform distribution over inputs in , there exist valid heat functions for each gate in Batcher's odd-even mergesort such that the expected total heat release across all gates is .
Proof. Adding up the expected heat dissipation for layers 1 through , we see that the total expected heat dissipation is
where the first term accounts for layers 1 and 2, and the second term accounts for gates in layers 3 to . The total heat dissipation for the whole circuit is therefore given by the recurrence
and so is when . The number of different heat functions used is per layer, and so is in total for the network.
C Re-deriving mismatch costs
In [WK20, YCW26, YYW26] the authors use the language of mismatch costs to lower bound the entropy production of implementing gates in a Boolean circuit. Instead of explicitly defining heat functions, they start with the assumption that some distribution over inputs minimizes the entropy production of the desired computation. Their main observation is that entropy production can be decomposed as the sum of a term characterizing how far the actual input distribution is from and a term characterizing the inefficiencies even when using as the input distribution. We start by characterizing how can be derived from a given heat function.
Lemma C.1. Let be an arbitrary function with domain and be a valid heat function for computing . Then any conditional input distribution that minimizes the entropy production of applying a gate computing with heat function must satisfy
on all where is defined. If is undefined, then all conditional input distributions have infinite entropy flow.
Proof. By the definition of entropy production, we have that for every y:
By Lemma 2.12, we know that is the distribution that minimizes this quantity. When is undefined, it must be the case that for every . In such cases, any distribution over these inputs must release infinite expected heat.
Corollary C.2. Let be an arbitrary function with domain and be a valid heat function for computing such that for some . Then any input distribution over that minimizes the entropy production of applying a gate computing with heat function must have conditional distributions and the distribution must only have support on the where is defined and that minimize .
Proof. The entropy production on an input distribution D is given by:
The entropy production can be expressed as a convex combination of the entropy production for the different conditional distributions. Lemma C.1 exactly characterizes what these conditional distributions look like. Due to convexity, any optimal distribution must have all of its probability mass on where is minimized.
We now use heat functions to reprove the decomposition of entropy production into the sum of terms first presented in [WK20]. Intuitively, in Proposition C.3, represents the distribution on inputs to gate for which the heat function is optimal (i.e., that minimizes entropy production), and represents the true distribution, incurring a higher entropy production. The difference is known as the mismatch cost. The significance of Proposition C.3 is that this mismatch cost can be characterized purely information theoretically in terms of and (specifically by the KL-divergence terms ). In other words the way the physics of the device implementing the gate influences the extra entropy production is entirely contained in its optimal distribution . Our proof of this result uses the language of heat functions, but is similar to that in [WK20].
Proposition C.3 ([WK20]). Let be a gate computing function with domain , and valid heat function . Let be any input distribution over , and be another input distribution over where and for every where both of these distributions are defined. If is undefined for some then . Otherwise, the entropy production of applying on is:
Proof. If then there must be some where . We would immediately have that and also while the remaining terms on the right-hand side of the equality would be finite. Thus, we can assume without loss of generality that .
Since we can rewrite Eq. (16) as:
(17)
Now by the definition of , for every , . This implies that this quantity has the same value for every element of the set . Therefore, any convex combination over the terms with the same values of will give the same value. This lets us rewrite Eq. (17) as:
as desired.
There are actually some subtlety in our statement of Proposition C.3 that becomes obvious with the language of heat functions. In particular, we cannot always take to be the distribution over inputs that minimizes the entropy production. Due to Corollary C.2, we know that such a would only have support on that minimize , and thus for many choices of we will not have that . Proposition C.3 actually has a nice intuitive interpretation in terms of heat functions. The term corresponds to how well suited is for the input distribution while corresponds to how close is to being optimal on the best possible distributions over the preimage of each .
D Entropy production from modularity
Heat functions only consider the inputs to a specific gate to determine the corresponding heat release. Thus, they do not account for correlations between the inputs to this gate and the rest of the circuit. This leads to a source of entropy production due to the locality of operations that are not injective. This source of entropy production was first identified in [WK20], where it was shown that the entropy production of applying a gate in a circuit is at least the drop in mutual information between the wires in this gate and the state of the remaining wires of the circuit. We prove essentially the same result, showing that it is an immediate consequence of the locality of valid heat functions.
Proposition D.1 ([WK20]). Let be a thermodynamic circuit with wires, and let be a partition of and be random variables for the state of the wires in after applying gate in . Let be the marginal distribution of random variable according to distribution . Then if gate computes the function and has valid heat function , the entropy production of applying as the next gate in is .
Proof. By Definition 2.25,
Let be the distribution over states of the circuit after applying . Since is the same as , we know that according to Definition 2.24:
as desired.
Thus we can decompose entropy production into a term based off of sub-optimal computation on the marginal input distribution plus the drop in mutual information caused by the locality constraint on heat functions.