Mismatch cost of computing: from circuits to algorithms
Abstract
Stochastic thermodynamics extends equilibrium statistical physics to systems arbitrarily far from thermal equilibrium, with arbitrarily many quickly evolving degrees of freedom. These features make it the correct framework for analyzing the thermodynamics of real-world computers. Specifically, it has been proven that the “mismatch cost” of a dynamic process is a lower bound on the energy dissipation, namely the entropy production (EP), of any physical system that implements that process. In particular, the mismatch cost for any periodic process — like every modern digital device — is strictly positive. Here we show that mismatch cost may be significant on the macroscopic scale, not just on the nanoscale (in contrast to many other stochastic thermodynamics bounds). We also show that the mismatch cost of systems that are coarse-grained in time and/or space still provides lower bounds to the microscopic entropy production of running such systems. We then argue that traditional computer science measures of algorithmic efficiency, focused on the resource costs of “space” and “time” complexity, should include a third cost — thermodynamic cost — and that mismatch cost is well-suited to bounding such a cost for arbitrary computational machines. Accordingly, we derive the mismatch cost for running an arbitrary Boolean circuit and for running an arbitrary Random Access Stored Program machine (a simplified model of a microprocessor).
I Introduction
I.1 Background
Recent decades have seen significant advancements in non-equilibrium statistical physics, particularly in stochastic thermodynamics seifert2012stochastic ; parrondo2015thermodynamics ; wolpert2019stochastic and open quantum thermodynamics kolchinsky2021dependence . These fields extend classical statistical physics to systems far from thermal equilibrium, including those with many degrees of freedom and thermal and quantum fluctuations, which are critical in small-scale systems. Stochastic thermodynamics provides the mathematical tools to describe energy dissipation, or entropy production (EP), in various systems, including biological processes, nano-machines, and single-molecule experiments.
The early work of Szilard, Landauer, and Bennett highlighted the thermodynamic properties of computation szilard1964decrease ; landauer1961irreversibility ; bennett1982thermodynamics . Their contributions laid the foundation for the modern understanding that information is physical and that physical processes, including computation, are governed by thermodynamic laws. Stochastic thermodynamics applies not only to nano-scale systems but also to systems of any size, providing a framework for describing entropy production in processes far from thermal equilibrium, with many rapidly evolving degrees of freedom. This makes stochastic thermodynamics an ideal framework for analyzing the thermodynamics of real-world digital devices.
In the field of computer science, the efficiency of algorithms has traditionally been measured in terms of two primary resources: space and time arora2009computational . These measures, known as space complexity and time complexity, capture the amount of memory and the duration of computation, respectively, required to solve a problem. While these dimensions are fundamental to software development and system design, they do not account for the thermodynamic costs inherent in computation. Space and time complexity focus on the logical and operational aspects of algorithms, but they overlook the physical resources required for executing computations, especially in terms of energy dissipation. While these dimensions are fundamental to software development and system design, we argue that a third dimension “THERMO"-complexity should also be considered. The thermodynamic perspective is not merely an extension but a necessity for fully understanding the costs of computation.
A central quantity in this analysis is the mismatch cost wolpert2020minimal ; kolchinsky2021dependence ; kolchinsky2017dependence , a lower bound to entropy production in physical systems that implement a given stochastic process. Mismatch cost is universal in that it applies to any system, regardless of whether the process is discrete or continuous in time, Markovian or not, quantum or classical, or whether the state space is countable or uncountable. More importantly, it provides a strictly positive lower bound to entropy production in periodic processes, a feature that is characteristic of most modern digital devices ouldridge2023thermodynamics ; manzano2024thermodynamics . This makes mismatch cost a crucial quantity for understanding the thermodynamic limits of real-world computing systems.
Additionally, mismatch cost applies to modular systems, where computational variables are statistically coupled without being physically linked boyd_different_2018 ; wolpert2020thermodynamics ; wolpert2019stochastic ; wolpert2020uncertainty . This concept strengthens the second law of thermodynamics, offering a thermodynamic lower bound on EP for processes that are either periodic or modular—features common in digital computation.
I.2 Contributions
This paper has several key contributions:
First, in Sec. II.2, we show that mismatch cost can be a significant contribution to the total EP at the macroscopic scale, in contrast to traditional lower bounds on EP which primarily focus on the nanoscale, such thermodynamic uncertainity relations (TURs) and speed limits.
Second, in Sec. II.3, we analyse the mismatch cost to systems that are coarse-grained in time and/or space, showing that even coarser resolution, the mismatch cost still provides a lower bound on the microscopic entropy production. This broadens the applicability of mismatch cost to any computational machine beyond the idealized, fine-grained models typically used in stochastic thermodynamics. This makes mismatch cost well-suited to quantify the thermodynamic cost for arbitrary computational machines.
Finally, in Sec. III and IV, we apply mismatch cost to two fundamental models of computation: Boolean circuits and Random Access Stored Program machines (a simplified model of microprocessors). We derive the mismatch cost for both models, providing concrete examples of how this thermodynamic measure can be used to assess the efficiency of computational systems.

II General properties of the mismatch cost
Consider a system with a state space that interacts with one or more heat baths and undergoes stochastic dynamics over a fixed time interval . At the initial time , the system’s state distribution is , which evolves into a final distribution at time . This evolution is expressed as , where . The map can be interpreted as an arbitrary computational transformation, mapping initial states to final states. It is known that many thermodynamic cost functions can be written as
(1) |
where represents a function defined for each state , while is the Shannon entropy of the distribution . The term quantifies the change in the system’s entropy during the process. In particular, corresponds to the thermodynamic entropy production (EP) when , where is a heat functional representing the heat flow out of the system starting in state . In this case, the term captures the average heat flow during the process for the initial distribution .
II.1 Mismatch cost
The prior distribution is defined as the initial distribution that minimizes , denoted as . The mismatch cost quantifies the portion of the cost arising from a mismatch between the actual initial distribution and a prior distribution that minimizes the cost (1), and it is given by:
(2) |
where is the KL divergence between distributions and . It has been shown that any cost function of the form (1) can be written in terms of the mismatch cost kolchinsky2017dependence ; kolchinsky2021dependence ; wolpert2020thermodynamics :
(3) |
where is called the residual cost. There are a couple of important things to note about the decomposition (3). First, is inherent to the dynamics of the process and does not depend on the actual initial distribution over the states of the system. Second, on the other hand, is a function of the actual initial distribution and it has a very limited dependence on the details of the underlying physical process primarily arising from the prior distribution . Moreover, due to the second law, always holdsseifert2012stochastic ; van2015ensemble , and therefore, mismatch cost always provides a lower bound to the EP:
(4) |
Equality is achieved when , indicating that the underlying physical process is thermodynamically reversible for a certain initial distribution. Calculating requires full knowledge of the system’s dynamics, which is rarely available for real physical systems. On the other hand, calculating mismatch cost only requires the knowledge of the map and the prior distribution . Therefore, for a specified computation , and given prior distribution for the physical substrate on which the computation is run, the mismatch cost formula (4) provides a lower bound on the EP. Moreover, if the same process is repeated many times over the same interval, the actual distribution over the states of the systems is . Since the underlying process is the same, the associated prior distribution would remain the same for each iteration, only the actual distribution over the states of the system modifies with each iteration. The mismatch cost in the iteration of the process is,
(5) | ||||
(6) |
Mismatch cost in Eq. (6) is called periodic mismatch cost. The total mismatch cost for -iterations of the process is obtained by summing over all the iterations
(7) |
It is important to note that even if the system initially begins with its actual distribution matching the prior distribution, the mismatch cost is zero only for the first iteration. After this initial step, the actual distribution over the system’s states will deviate from the prior distribution, leading to a non-zero mismatch cost in subsequent iterations. Thus, Eq. (7) establishes an unavoidable non-zero EP in any repeated process. Figure 2 illustrates a straightforward example of a map that is applied repeatedly over a system’s state space, showing the mismatch cost contribution to the EP in each iteration.


In the following sections, we examine the properties of and analyze its dependence on the details of the underlying physical system. Additionally, we demonstrate that the mismatch cost can constitute a substantial portion of the total EP, highlighting the practical utility of the bound in Eq. (4).
II.2 The prior distribution and the worst-case mismatch cost
It’s clear from the definition (1) that the prior distribution depends on and , where is thermodynamically interpretation as the average heat flow from the system to the environment during the evolution over , when the system is initialized in state .
It’s important to mention that the prior is always in the interior of the probability simplex . This is proved in Appendix (A). In other words, the prior distribution assigns non-zero probability to every state in the state space . By ensuring that remains in the interior of the simplex, the mismatch cost remains well-behaved and finite for any initial distribution .
Moreover, if values are sufficiently large for all relative to the change in system’s Shannon entropy in (1), then will primarily determine . In such cases, if is not uniform across all states—meaning is higher for some states than others—the associated prior distribution will take on lower values for those higher-weighted states compared to the rest.
Put differently, the prior distribution will shift closer to the boundary of the probability simplex. The greater the non-uniformity of across states, the nearer the prior will be to the simplex edge. In that case, any typical actual distribution on the simplex that is not close to the edge would yield a significantly high value of KL-divergence . This intuitive idea is formalized in Appendix C to prove that the mismatch cost could get at least as large as the difference between maximum and minimum value of minus .
(8) |
Here, is the worst-case mismatch cost, i,e., when the actual distribution is furthest away from the prior distribution. Remember that thermodynamically, represents the average heat flow terms. Result (8) highlights that in the physical scenario where the heat flow terms are significantly large compared to , the mismatch cost could amount to a significant portion of the total EP. This situation is particularly relevant for mesoscopic processes where the heat generated is large enough to be measurable, in contrast to microscopic stochastic systems where the heat generated is typically negligible.
There are other known lower bounds on EP, such as the Thermodynamic Uncertainty Relation (TUR)s barato2015thermodynamic ; gingrich2016dissipation ; horowitz2020thermodynamic and speed limits shiraishi2018speed ; vo2020unified . The TUR provides a bound on the trade-off between EP and the precision of a thermodynamic current. For a system with current , the TUR takes the form:
(9) |
where is the mean current, is its variance, and is the mean EP. This inequality bounds the variance of observable quantities in terms of the EP, making it a useful tool for stochastic processes. However, the TUR does not apply to deterministic processes, such as computational algorithms, and does not explicitly address the role of initial distributions.
Speed limits, on the other hand, place constraints on the minimum time required for a system to evolve between two states, given the amount of energy dissipated in the process. Other recent studies have developed techniques for estimating EP using limited system observables kawai2007dissipation ; roldan2010estimating ; bisker2017hierarchical ; harunari2022learn ; pietzonka2024thermodynamic and for analyzing EP based on the dynamics of coarse-grained systems degunther2024fluctuating ; gomez2008lower .
Mismatch cost differs from both the TUR and speed limits in that it focuses on the additional EP resulting from the mismatch between the actual initial distribution and the prior distribution . Unlike TUR and speed limits, the mismatch cost framework is general enough to apply to both stochastic and deterministic processes, including computational algorithms and logical circuits. In this sense, mismatch cost provides a more versatile tool for analyzing EP across a wide range of physical and information-theoretic systems, offering insights that complement the TUR and speed limits by directly addressing the effects of non-optimal initial conditions.
II.3 Coarse-graining
The mismatch cost lower bound on EP associated with a computation depends significantly on the time resolution at which the computation process is observed. For example, when a circuit runs, advancing the computation across it’s gate, one could calculate the mismatch cost at a finest time resolution, where the contribution from each gate’s operation is accounted for individually as it runs. Alternatively, a coarser time resolution might involve calculating the mismatch cost for groups of gates after they complete their operations, or even at the coarsest level, where the mismatch cost is determined solely from the initial and final states of the entire circuit. Understanding how mismatch cost behaves under varying levels of temporal granularity is therefore crucial.
Consider a computation occurring over the time interval . This interval can be partitioned into two subintervals, and , where is an intermediate time satisfying . Let be the map that evolves an initial distribution to a distribution at the intermediate time , i.e. during , and let operate on the second time interval, with during . The EP during the time interval , denoted as , can be expressed as the sum of the EP generated during the sub-intervals and . Formally:
(10) |
By definition, the residual cost over the interval is
(11) |
Since and , therefore
(12) |
If the process begins with an initial distribution that matches the prior distribution for the entire interval , such that , then at the intermediate time , the prior distribution evolves to , where represents the transition dynamics up to time . Since the EP over the full interval can be broken into contributions from the two subintervals, we can write:
(13) |
It is important to note that, in general, does not serve as the prior for the process during the remainder of the interval . As a result, the residual cost . Consequently, the residual cost over the full interval satisfies the inequality:
(14) |
(15) |
The inequality above implies that the mismatch cost calculated at a coarser time resolution is always lower than or equal to the sum of the mismatch costs calculated at finer time resolutions over the same interval.
An analogous consideration for comparing mismatch costs under spatial coarse-graining does not hold. In the case of spatial resolutions, one can either analyze the mismatch cost at a finer resolution or at a coarser resolution, but a direct comparison between the two is not possible. Nonetheless, the mismatch cost calculated at a coarser spatial resolution continues to provide a valid lower bound on the entropy production at the finer resolution. This is elaborated upon in Appendix B.
Building on this observation, the following sections systematically apply the mismatch cost formula to Boolean circuits, deriving lower bounds on the EP associated with each step of computation within a circuit.
III Mismatch Cost for Running a Boolean Circuit
Boolean circuits play a fundamental role in digital computation. They allow logical operations to be represented and manipulated using simple binary inputs and outputs. One of the most intriguing aspects of Boolean circuits is their universality, meaning that any logical or arithmetic operation can be implemented using combinations of basic logic gates like AND, OR, and NOT gatesArora2009 . This universality underscores their importance in digital design, as they provide a versatile framework for constructing a wide range of computational functions. For any Boolean function, there are countless ways to construct a circuit that can implement it. Each circuit configuration may differ in terms of its architecture, topology, and component arrangement. The features of thermodynamic cost across all these possible circuits are close to unknownWolpert2020 . In this section we apply mismatch cost to Boolean circuits.
III.1 Circuit theory
Formally, a loop-free circuit is a directed acyclic graph (DAG) denoted by . is the set of nodes or gates and denotes the set of directed edges connecting nodes. The direction of each edge indicates the dependency between nodes, allowing one to enumerate the nodes in in a specific sequence. A topological ordering of the nodes satisfies the condition that for every directed edge from node to node , node precedes node in the ordering (). The state space of a node is denoted by , and its state is represented by . The joint state space of the circuit is given by .
A node has incoming edges from nodes known as its parent nodes and outgoing edges to nodes known as its children nodes. The joint state of the parent nodes is denoted by , and the joint state of the children nodes is denoted by . The input nodes, or root nodes, have no incoming edges from other nodes. The output gates, or leaf nodes, have no outgoing edges to other nodes. Running a gate means updating it’s state based on the state of its parent nodes. This dependency is expressed with the conditional distribution .
Gates can also be organized into groups known as layers, based on their connectivity, and a similar topological ordering can be applied to these layers. To preserve the generality of the analysis, in what follows, may represent either a single gate or an entire layer of gates, where denotes the layer’s position in the topological order. One can also discuss the parent layer and child layer, with dependencies expressed as . The entire sequence is called an execution cycle and running a gate or a layer of gates is a step in execution cycle.
Running a circuit can be conceptualized as sequentially updating it gate-by-gate or layer-by-layer. This approach reflects how circuits are implemented in real-world scenarios. Another key observation is that circuits in all computational devices are reused repeatedly. Each time a circuit is used, it undergoes the same sequential process: starting with the new input values, followed by updating the subsequent layers, and so on. We will incorporate this observation into our analysis. We also assume that after each complete run of the circuit, the values of each gate remain as they were and are not reinitialized to any special state before beginning the next cycle.
Let’s consider that input are sampled from the distribution . This input distribution induces a distribution over the joint state of the circuit. The joint distribution over the circuit after it’s first run is
(16) |
We will keep refereeing back to the total joint distribution in (16). Since the gates are not re-initialized to any special state before the circuit is used for the next run, the joint distribution over the state of circuit is given by (16). Before re-using the circuit, values of the input nodes are over-written with new values which are sampled from . Meanwhile, other non-input nodes remain unchanged. Therefore, after overwriting inputs, distribution over the joint state of the circuit is,
(17) |
where is the marginal distribution over non-input nodes.
III.2 Mismatch cost of overwriting with new inputs
During the process of overwriting new input values, the input nodes evolve independent of the rest of the non-input nodes which remain unchanged. Therefore, updating input nodes with new values is a sub-system process where the sub-system evolves independently of while the later remains unchanged. The prior distribution for this subsystem process is product distribution, expressed as . Since new values of the input nodes are sampled from , this prior distribution evolves to .
(18) |
while the actual distribution evolves from to :
(19) |
Since new input values are totally independent of the states of the rest of the gates, , and the drop in mutual information is
(20) | ||||
(21) |
The mismatch cost of overwriting the input values is
(22) | ||||
(23) |
III.3 Gate-by-gate or layer-by-layer implementation of the circuit
After overwriting the input nodes with new values, the gates in the next immediate layer are updated based on these inputs, followed by the subsequent layers, and so on. The gates in each layer can be updated either one at a time, which we refer to as a gate-by-gate implementation, or all at once, which is termed as a layer-by-layer implementation. Each step in the execution cycle modifies the probability distribution over the state of the circuit.
Let’s assume we are in the middle of the execution cycle. Using our previous notation, let represent the state of the gate or layer of gates that is about to be updated based on the values of its parent nodes. Let denote the joint state of all the gates that have already been updated based on the new inputs, including the input nodes themselves. The set also includes the parent layer(s) of . Finally, let denote all the gates that are to be updated after , that is, all the gates whose update occurs following the update of . and are correlated form the previous run of the circuit, while which has values from the new run, is independent of and . Therefore, the distribution over the state of circuit right before updating is
(24) |
where is the marginal distribution over and . The distribution over is and it’s same as marginalizing over and , .
When is updated based on the new values of it’s parent which are in , it gets correlated with and at the same time, it’s new value is independent of the value of from the previous run. Therefore, after updating , the new distribution is
(25) |
where and .
We express this change in the distribution when updates by writing
(26) |
III.4 Mismatch cost of gate-by-gate or layer-by-layer implementation of the circuit
When is updated based on the values of its parents , the rest of the nodes are unchanged. This makes it a subsystem process where and form a subsystem. The prior distribution therefore is a product distribution
(27) |
where denotes the joint state of all the gates in the circuit except for and . evolves to
(29) | ||||
(30) |
which after simplification (details in the Appendix D) becomes
(31) |
where is the mutual information between and its children
(32) |
The total mismatch cost of running the entire circuit with sequential gate-by-gate or layer-by-layer execution is the sum of subsystem mismatch costs. For a gate-by-gate run, the total mismatch cost is
(33) |
where . In a layer-by-layer run, the sum is over all the layers
(34) |
As discussed in the Sec. II.3, the mismatch cost of gate-by-gate implementation of the circuit is always going to be lower bounded by the mismatch cost calculated for layer-by-layer implementation of the circuit.
IV Mismatch Cost for Digital Devices: from microprocessors to algorithms
Fig. 1 illustrates the concept of an algorithm running on an underlying chip, which is composed of various interconnected circuits. This (generic) chip contains several underlying variables that are used to execute the algorithm. The key insight here is that the coarse-graining result discussed in Sec. II.3 suggests that even when focusing solely on the variables directly involved in the algorithm—without delving into the complex mechanisms within the microprocessor—the mismatch cost associated with these algorithmic variables still provides a lower bound on the entropy production (EP) in the microprocessor executing the algorithm. In other words, the mismatch cost associated to the algorithm itself remains a lower bound for the total mismatch cost of running the process on the physical substrate.
To calculate the mismatch cost associated with the changes in the values of the algorithm, we begin by discussing the different types of variables involved in the operation of the algorithm and how their values evolve as the algorithm progresses through the computation. Next, we formalize these changes in the context of periodic machines, providing a structured framework for understanding and calculating the mismatch cost throughout the process.
IV.1 Algorithms
In most programming languages, statements are executed sequentially unless altered by control flow statements such as loops or conditionals. Each codeline represents a single instruction, executed in the order it appears in the code. The interpreter or compiler tracks which codeline is currently being executed, aiding in program flow understanding and debugging. At the hardware level, this is managed by a program counter (PC) or instruction pointer (IP), a register that holds the memory address of the next instruction to execute. The PC is updated after each instruction, pointing to the next, unless a control flow statement (e.g., jump operations) modifies the sequence.
In a microprocessor, commands are stored in memory as binary codes, each corresponding to a specific instruction (e.g., the "JMP" instruction in the Intel 8080 was represented by an 8-bit code). The memory addresses are sequential, and the program counter increments by one unless a jump operation occurs.
The following simple example in pseudocode illustrates this process:
function result = add(a, b) % Start at codeline 1 current_codeline = 1; % Codeline 2: Add a and b result = a + b; current_codeline = current_codeline + 1; % Codeline 3: Return the result end
The algorithm involves four variables, two input variable a
and b
, a line counter current_codeline
, and an output variable result
. The line counter, along with the algorithm’s variables, is sufficient to describe the state of execution, as it tracks which part of the program is currently running.
IV.2 Periodic machines
We formally define an algorithm by the tuple , where x represents the set of all variables, including the program counter, which define the state of the algorithm at any given step . Together, and x can be written as . represents the state space of the algorithm, which is the set of all valid states x for the algorithm. is a transition map that updates the state of the algorithm from to :
(35) |
The algorithm starts with , with it’s program counter being at 0. When the algorithm halts, the map reaches a fixed point. The dynamics of the algorithm induces a corresponding evolution on the probability distribution over the state space . To formalize this, we enumerate each state and construct a transition matrix with elements , where represents the probability of transitioning from state to state . If state does not transition to state , then . For deterministic algorithms, takes values of 0 or 1, reflecting the deterministic nature of state transitions. For probabilistic algorithms, represents the probability of transitioning from state to state . The discrete-time evolution of the probability distribution over the state space is described by the linear map :
(36) |
where denotes the probability distribution over the state space after step . As the algorithm progresses and eventually halts, this distribution converges to a steady-state distribution.
We can apply the periodic mismatch cost discussed in Eq. (7). If algorithm starts with an initial distribution . The mismatch cost for the first iteration is expressed as:
(37) |
The distribution over the states of the algorithm evolves to , but the prior distribution for the periodic process remains the same. Therefore, the mismatch cost in the second iteration is
(38) |
The mismatch cost for the -th iteration is given by:
(39) |
If it takes iteration for the algorithm to halt, the total mismatch cost for running the entire algorithm is the sum of the mismatch costs across all iterations:
(40) |
IV.3 Resetting cost and the initial state of the algorithm
When choosing an initial distribution , it is crucial to account for the properties of the variables involved in the algorithm. Typically, an algorithm starts with its line counter set to 0, and includes both input and non-input variables. Non-input variables may consist of loop counters, flags, and other auxiliary variables initialized to specific values. As a result, the algorithm’s initial state sets these special variables, like the line counter and loop counters, to their initialized values with certainty. Meanwhile, the input variables are sampled from a distribution , and the non-input variables are assumed to retain their values from the previous execution. For the purposes of this discussion, we assume that non-input variables retain the values at the end of the previous execution. Thus, the initial distribution over the state space of the algorithm is primarily determined by , the distribution over the input variables.
Similar to circuits, it’s important to consider the thermodynamic cost associated with updating the input variables with new values. When the algorithm is executed, its state variables retain the values from the previous execution. To reuse the algorithm for new inputs, the input variables must be rewritten, and the special variables need to be reinitialized to their starting values.
Let represent the joint distribution of the algorithm’s state after the previous run. We will use the following notation: denotes the input variables, represents the non-input variables, and indicates the special variables, including the line counter.
Before the new input values are overwritten and the special variables are reinitialized, the state is given by the joint distribution:
(41) |
Note that the initial distribution is always a joint distribution, as all variables are statistically coupled at the end of the algorithm’s execution. After overwriting the input variables, sampled from , and reinitializing the special variables, the distribution decomposes as:
(42) |
where is the marginal distribution over the non-input variables, and indicates that the special variables are reinitialized with probability 1.
The mismatch cost due to this overwriting process is given by:
(43) |
where is the prior distribution before overwriting, and is the updated prior distribution after overwriting. This results in the following mismatch cost:
(44) |
The thermodynamic cost of overwriting before reusing a computational system is not confined to algorithms or circuits. It also applies to any physical system involving overwriting, such as memory systems. For example, dynamic random-access memory (DRAM), solid-state drives (SSD), and flash memory all require periodic refreshing or updating of their stored information, leading to similar considerations of mismatch cost and heat dissipation.
IV.4 RASP Examples
IV.4.1 RASP
While coding a realistic example of a microprocessor function would be beyond the purpose of this paper, it is worth exploring the simplest example that mimics the functioning of a realistic device. The example we propose is then a restricted version of the Random Access Stored Program (RASP) elgot1964random , which operates as a Universal Turing Machine (UTM) integrated into a Random-Access Machine (RAM) infrastructure. Unlike the conventional UTM, which relies on a universal finite-state table to interpret any properly structured program on its tape, the RASP adopts a unique approach and stores both program instructions and data within designated registers.
While the UTM expects to encounter Turing 5-tuples on its tape, the RASP accommodates a broader range of program sets, provided its finite-state table can interpret and execute them. Alongside the program, input parameters are typically positioned to the right, with output data following suit. To initiate the operation, the user has to position the RASP’s head over the initial instruction and it ensures that the input adheres to the specified format for both the tape program and the finite-state machine’s instruction table.
The RASP’s operational mechanism mirrors this setup: programs and data reside within registers, similar to a UTM’s tape. However, unlike the UTM’s non-linear access pattern, the RASP accesses instructions sequentially, closer to the operation of a microprocessor. It follows a predetermined path unless directed elsewhere by conditional tests. This characteristic feature distinguishes the RASP, highlighting its capability to execute programs systematically within a structured, sequential framework.
For instance, let us consider this pseudocode for a Heaviside -function :
if x > 0 % IT IS POSITIVE - line code execution else if x == 0 % IT IS ZERO - line code execution else % IT IS NEGATIVE - line code execution end
In lower-level (microprocessor-like) RASP, this becomes
LOAD R1, x ; Load value of x into register R1 CMP R1, 0 ; Compare R1 with 0 JG POSITIVE ; Jump to POSITIVE if R1 > 0 JE ZERO ; Jump to ZERO if R1 == 0 JL NEGATIVE ; Jump to NEGATIVE if R1 < 0
Above, POSITIVE, ZERO and NEGATIVE are program lines associated with the routines being called later in the code and stored in the memory array.
Simulating a RASP code is a difficult task. However, we can emulate the behavior using a higher-level programming language by keeping track of the code line. This is why, for the sake of the present paper, we do not distinguish between program counters and codelines. To see this, let us now convert this code to a pseudo-code to clarify how to keep track of the codeline. This is given by the code:
% Define the variables x = 5; % Example value line = 1; % Initialize the line number % LOAD R1, x R1 = x; fprintf(’Line %d: LOAD R1, x’, line, R1); line = line + 1; % CMP R1, 0 cmp_result = R1 - 0; fprintf(’Line %d: CMP R1, 0’, line, cmp_result); line = line + 1; % JG POSITIVE if cmp_result > 0 fprintf(’Line %d: JG POSITIVE\n’, line); % POSITIVE section fprintf(’Line POSITIVE: R1 is positive\n’); return; % Exit after the jump else line = line + 1; end % JE ZERO if cmp_result == 0 fprintf(’Line %d: JE ZERO\n’, line); % ZERO section fprintf(’Line ZERO: R1 is zero\n’); return; % Exit after the jump else line = line + 1; end % JL NEGATIVE if cmp_result < 0 fprintf(’Line %d: JL NEGATIVE\n’, line); % NEGATIVE section fprintf(’Line NEGATIVE: R1 is negative\n’); return; % Exit after the jump end
We see that in order to keep track of the codeline, we need to introduce a line parameter. Similarly, we consider for instance the following pseudo-code for a Heaviside theta-function:
function a = thetaf(x, c) if (x > c) a = 1; else a = 0; end end
In RASP, this could be represented as:
1: LOAD x, R1 ; Load x into register R1 2: LOAD c, R2 ; Load c into register R2 3: CMP R1, R2 ; Compare the values in R1 and R2 4: JLE 7 ; If R1 <= R2, jump to line 7 5: SET R3, 1 ; Set R3 (a) to 1 if R1 > R2 6: JMP 8 ; Jump to the end of the program 7: SET R3, 0 ; Set R3 (a) to 0 if R1 <= R2 8: END End of the program
A detailed explanation of the program above is provided in Appendix E.
These examples show the necessity to expand the phase space of a higher-level code to incorporate codelines to fully represent the correct algorithmic flow into the mismatch cost analysis.
IV.4.2 Incorporating Codelines in Phase Space Representation
In view of our interest in calculating the mismatch cost for algorithms, let us now discuss how to incorporate the codelines into the phase space of an algorithm. The phase space can be thought of as the cross product of all possible values of the program’s variables at any given point in time. This includes, Input Variables, Internal Variables and Output variables. The difference between the two should be clear in the context of the program. However, to fully represent the state of the system, particularly in the context of lower-level algorithms like those in a Random Access Stored Program (RASP) machine described so far, the current line of code being executed must also be included. This is because the behavior of the program depends not only on the values of its variables but also on the specific instruction being executed at any given moment. Incorporating the codeline into the phase space representation is crucial for several reasons. At a more general level, it helps with the program’s control flow, which dictates the sequence of operations. Without it, the phase space would be incomplete, as it would lack the information about which operation is currently affecting the variables. Moreover, each codeline corresponds to a specific state transition. For instance, whether the program will branch (jump to a different line) or continue sequentially depends on the current codeline. The reason why it is important here, is that different lines can perform different operations on the same set of variables. The codeline provides context to these operations, ensuring that the phase space accurately reflects the program’s dynamic behavior.
To fully represent the phase space of a lower-level algorithm, we must include the current codeline as part of the state. This can be achieved by explicitly tracking and updating the codeline during the program execution. Using the same RASP code above, let us now introduce the transition between states as our map.
In the context of the given RASP code, we can think of the algorithm as a map between different states. The states are represented by the cross-product of the variables and the current line of code (codeline). This forms a state machine where each state is a combination of variable values and the current execution point within the code. The algorithm deterministically transitions from one state to another based on the logic of the program.
Let us define the state of the system as a tuple consisting of R1: Value of register R1; cmp_result which is associated with the result of the comparison operation; codeline: Current line of code being executed.
Thus, the state can be written as the tuple .
Some examples of state transitions are provided in Appendix E.
IV.4.3 Analysis
In this section, we examine the thermodynamic mismatch cost associated with the Random-access stored-program machine algorithm introduced in Sec. IV.4.1, as introduced earlier in the manuscript. The algorithm, represented as state transitions in Fig. 3 (bottom), explores the relationship between the prior distribution and the periodic mismatch cost (PMC) in the context of the RASP. The prior was determined by solving the minimum of the mismatch cost function, ensuring optimal initial conditions. Sampling over these initial conditions has generated phase space diagrams, providing a comprehensive view of the system’s behavior 111The MATLAB code for this study is available online at:https://github.com/Kensho28/RASP..
The analysis focuses on the maximum algorithmic length, defined as the distance between the input state and the absorbing state, which in this case is 3. We then plot the periodic mismatch cost as a function of the parameter . The prior distribution is constructed by assuming a random probability initial distribution , following the relationship . This formulation allows us to investigate the influence of on the RASP’s PMC.
Our analysis reveals that the PMC of the RASP algorithm increases as a function of . Unsurprisingly, when , the PMC is zero. As increases, the contribution of the random distribution to becomes more significant, leading to an increase in the mismatch cost. This result underscores the sensitivity of the RASP algorithm’s thermodynamic efficiency to variations in the initial probability distribution.


V Conclusions
In this study, we have explored the thermodynamic cost of computation by leveraging on the concept of mismatch cost, a lower bound on EP that quantifies the thermodynamic inefficiency arising from deviations between actual and optimal initial distributions in computational processes. This work extends the classical understanding of algorithmic efficiency, traditionally defined in terms of space and time complexity, by incorporating thermodynamic complexity as a critical third dimension.
Our investigation reveals that the mismatch cost is a fundamental aspect of all computational processes. In this work, we explored in particular Boolean logic circuits and Random-Access Stored Program (RASP) architectures, but the techniques we developed can be used in other contexts. For logic gates and circuits, we have demonstrated that the thermodynamic cost is intrinsically linked to the mutual information shared among gates of the circuit. This mutual information results in unavoidable heat dissipation. This insight underscores the inherent thermodynamic cost associated with digital computation at the most fundamental levels.
In analyzing RASP architecture, we have shown that the mismatch cost increases as the input distribution deviates from an optimal configuration. This finding highlights the sensitivity of computational thermodynamic efficiency to the initial conditions of the system. The RASP example further illustrates the necessity of expanding the phase space to include programmatic variables such as the codeline (or at a more fundamental level the program counter), which plays a crucial role in accurately modeling and analyzing the thermodynamic costs of algorithms. This approach provides a more comprehensive framework for evaluating the thermodynamic implications of algorithm execution, especially in systems where sequential and conditional operations are integral to the computational process.
Coarse-graining, both in space and time, has been identified as a powerful (and necessary) tool for understanding and bounding the thermodynamic costs associated with computation. By aggregating computational steps or grouping variables, coarse-graining allows for the derivation of lower bounds on microscopic heat dissipation. These bounds are vital for understanding the scaling behavior of thermodynamic costs in computational processes and offer practical insights into the design of more thermodynamically efficient systems.
Finally, we have derived theoretical bounds on the worst-case mismatch cost, providing a limit on the thermodynamic inefficiency that can be expected in real-world computational systems. These bounds emphasize the importance of optimizing computational architectures to minimize EP, which remains a critical challenge in the design and operation of modern digital systems.
In conclusion, the present manuscript advances our understanding of the interplay between computation and thermodynamics, offering a new perspective on the costs associated with digital operations. We strongly believe that by incorporating thermodynamic considerations into the analysis of algorithms and computational systems, it is possible to pave the way for more energy-efficient computing technologies. This research not only contributes to the theoretical foundations of computational thermodynamics but also has practical implications for the future of digital system design and optimization.
References
- [1] Udo Seifert. Stochastic thermodynamics, fluctuation theorems and molecular machines. Reports on Progress in Physics, 75(12):126001, 2012.
- [2] Juan MR Parrondo, Jordan M Horowitz, and Takahiro Sagawa. Thermodynamics of information. Nature Physics, 11(2):131–139, 2015.
- [3] David H Wolpert. The stochastic thermodynamics of computation. Journal of Physics A: Mathematical and Theoretical, 52(19):193001, 2019. See arXiv:1905.05669 for updated version.
- [4] Artemy Kolchinsky and David H Wolpert. Dependence of integrated, instantaneous, and fluctuating entropy production on the initial state in quantum and classical processes. Physical Review E, 104(5):054107, 2021.
- [5] Leo Szilard. On the decrease of entropy in a thermodynamic system by the intervention of intelligent beings. Behavioral Science, 9(4):301–310, 1964.
- [6] Rolf Landauer. Irreversibility and heat generation in the computing process. IBM journal of research and development, 5(3):183–191, 1961.
- [7] Charles H Bennett. The thermodynamics of computation—a review. International Journal of Theoretical Physics, 21:905–940, 1982.
- [8] Sanjeev Arora and Boaz Barak. Computational complexity: a modern approach. Cambridge University Press, 2009.
- [9] David H Wolpert. Minimal entropy production rate of interacting systems. New Journal of Physics, 22(11):113013, 2020.
- [10] Artemy Kolchinsky and David H Wolpert. Dependence of dissipation on the initial distribution over states. Journal of Statistical Mechanics: Theory and Experiment, 2017(8):083202, 2017.
- [11] Thomas E Ouldridge and David H Wolpert. Thermodynamics of deterministic finite automata operating locally and periodically. New Journal of Physics, 25(12):123013, 2023.
- [12] Gonzalo Manzano, Gülce Kardeş, Édgar Roldán, and David H Wolpert. Thermodynamics of computations with absolute irreversibility, unidirectional transitions, and stochastic computation times. Physical Review X, 14(2):021026, 2024.
- [13] Robert Boyd. A different kind of animal: how culture transformed our species. University Center for Human Values series. University Press, Princeton, 2018. HOLLIS number: 990152078900203941.
- [14] David H Wolpert and Artemy Kolchinsky. Thermodynamics of computing with circuits. New Journal of Physics, 22(6):063047, 2020.
- [15] David H Wolpert. Uncertainty relations and fluctuation theorems for bayes nets. Physical Review Letters, 125(20):200602, 2020.
- [16] Christian Van den Broeck and Massimiliano Esposito. Ensemble and trajectory thermodynamics: a brief introduction. Physica A, 418:6–16, 2015.
- [17] Andre C Barato and Udo Seifert. Thermodynamic uncertainty relation for biomolecular processes. Physical review letters, 114(15):158101, 2015.
- [18] Todd R Gingrich, Jordan M Horowitz, Nikolay Perunov, and Jeremy L England. Dissipation bounds all steady-state current fluctuations. Physical review letters, 116(12):120601, 2016.
- [19] Jordan M Horowitz and Todd R Gingrich. Thermodynamic uncertainty relations constrain non-equilibrium fluctuations. Nature Physics, 16(1):15–20, 2020.
- [20] Naoto Shiraishi, Ken Funo, and Keiji Saito. Speed limit for classical stochastic processes. Physical review letters, 121(7):070601, 2018.
- [21] Van Tuan Vo, Tan Van Vu, and Yoshihiko Hasegawa. Unified approach to classical speed limit and thermodynamic uncertainty relation. Physical Review E, 102(6):062132, 2020.
- [22] Ryoichi Kawai, Juan MR Parrondo, and C Van den Broeck. Dissipation: The phase-space perspective. Physical review letters, 98(8):080602, 2007.
- [23] Édgar Roldán and Juan MR Parrondo. Estimating dissipation from single stationary trajectories. Physical review letters, 105(15):150607, 2010.
- [24] Gili Bisker, Matteo Polettini, Todd R Gingrich, and Jordan M Horowitz. Hierarchical bounds on entropy production inferred from partial information. Journal of Statistical Mechanics: Theory and Experiment, 2017(9):093210, 2017.
- [25] Pedro E Harunari, Annwesha Dutta, Matteo Polettini, and Édgar Roldán. What to learn from a few visible transitions’ statistics? Physical Review X, 12(4):041026, 2022.
- [26] Patrick Pietzonka and Francesco Coghi. Thermodynamic cost for precision of general counting observables. Physical Review E, 109(6):064128, 2024.
- [27] Julius Degünther, Jann van der Meer, and Udo Seifert. Fluctuating entropy production on the coarse-grained level: Inference and localization of irreversibility. Physical Review Research, 6(2):023175, 2024.
- [28] Alex Gomez-Marin, Juan MR Parrondo, and Christian Van den Broeck. Lower bounds on dissipation upon coarse graining. Physical Review E—Statistical, Nonlinear, and Soft Matter Physics, 78(1):011107, 2008.
- [29] Sanjeev Arora and Boaz Barak. Computational Complexity: A Modern Approach. Cambridge University Press, Cambridge, 2009.
- [30] David H Wolpert and Artemy Kolchinsky. Thermodynamics of computing with circuits. New Journal of Physics, 22:063047, 2020.
- [31] Calvin Elgot and Abraham Robinson. Random-access stored-program machines, an approach to programming languages. Journal of the Association for Computing Machinery, 11(4):365–399, October 1964.
- [32] Massimiliano Esposito. Stochastic thermodynamics under coarse graining. Physical Review E, 85(4):041125, 2012.
Appendix A Proofs of prior distribution delocalized on states
Consider a conditional distribution that specifies the probability of “output” given “input” , where and are finite.
Given some , the island decomposition of , and any , let indicate the total probability within island , and
(45) |
indicate the conditional probability of state within island .
In our proofs below, we will make use of the notion of relative interior. Given a linear space , the relative interior of a subset is defined as [borwein2003notions]
(46) |
Finally, for any function , we use the notation
(47) |
to indicate the right-handed derivative of at . When the condition that is omitted, is implicitly assumed to equal , i.e.,
(48) |
We also adopt the shorthand that , and write , , and so .
Proofs
Given some conditional distribution and function , we consider the function as
(49) |
Note that is continuous on the relative interior of .
Lemma A1.
For any , the directional derivative of at toward is given by
(50) |
Proof.
Using the definition of , write
(51) |
Consider the first term on the RHS,
Evaluated at , the last line can be written as
where we adopt the convention that if for some , then this expression means . We next consider the term,
Combining the above gives
∎
Importantly, A1 holds even if there are ’s for which but , in which case the RHS of the equation in the lemma equals . (Similar comments apply to the results below.)
Theorem 1.
Let be a convex subset of . Then for any and any ,
(52) |
Equality holds if is in the relative interior of .
Proof.
Define the convex mixture . By A1, the directional derivative of at in the direction is
At the same time, , since is a minimizer within a convex set. 52 then follows by rearranging.
When is in the relative interior of , for sufficiently small . Then,
where in the first inequality comes from the fact that is a minimizer, in the second line we change variables as , and the last line we use the continuity of on interior of the simplex. Combining with the above implies
∎
The following result is key. It means that the prior within an island has full support in that island.
Lemma A2.
For any and ,
Proof.
We prove the claim by contradiction. Assume that is a minimizer with . Note there cannot be any and such that (if there were such an , then , contradicting the statement that ). Thus, by definition of islands, there must be an , such that and .
Define the delta-function distribution and the convex mixture for . We will also use the notation .
Since is a minimizer of , . Since is convex, the second derivative and therefore for all . Taking and in A1 and rearranging, we then have
(53) |
where the second inequality uses that is a minimizer of . At the same time,
(54) |
where in the second line we’ve used that , and in the third that , so and .
The following result is also key. Intuitively, it follows from the fact that the directional derivative of into the simplex for any on the edge of the simplex is negative infinite.
Lemma A3.
For any island , is unique.
Proof.
Consider any two distributions , and let , . We will prove that .
First, note that by A2, . By 1,
where the last line uses the log-sum inequality. If the inequality is strict, then and can’t both be minimizers, i.e., the minimizer must be unique, as claimed.
If instead the inequality is not strict, i.e., , then there is some constant such that for all with ,
(55) |
which is the same as
(56) |
Now consider any two different states such that and for some (such states must exist by the definition of islands). For 56 to hold for both with that same, shared , it must be that . Take another state such that and for some . Since this must be true for all pairs , for all , and , as claimed. ∎
Lemma A4.
.
Proof.
First, for any island , define
In words, is the subset of output states in that receive probability from input states in . By the definition of the island decomposition, for any , only if . Thus, for any and any , we can write
(57) |
Using and linearity of expectation, write .
We are now ready to prove the main result of this appendix.
Theorem 2.
Consider any function of the form
where is some conditional distribution of given and is some function. Let be any subset of such that for , and let be any distribution that obeys
Then, each will be unique, and for any with ,
Proof.
We prove the theorem by considering two cases separately.
Case 1: . This case can be assumed when for all , so that . Then, by A4, we have . By A2 and 1,
where we’ve used that if some , then is in the relative interior of the set . is unique by A3.
At the same time, observe that for any ,
The theorem follows by combining.
Case 2: . In this case, define a “restriction” of and to domain as follows:
-
1.
Define via for .
-
2.
Define the conditional distribution for via for all .
In addition, for any distribution with , let be a distribution over defined via for . Now, by inspection, it can be verified that for any with ,
(58) |
We can now apply Case 1 of the theorem to the function , as defined in terms of the tuple (rather than the function , as defined in terms of the tuple ). This gives
(59) |
where, for all , is the unique distribution that satisfies .
Appendix B Spatial-coarse graining
A computational degree of freedom, such as the logical state of a digital gate, is simply a coarse-grained representation of the underlying physical microstates. When applying mismatch cost formula to computation processes, it’s important to discuss the criterion under which mismatch cost provides a lower bound to the EP of the underlying physical process. Consider a system described at a finer level by variables and . The EP incurred during the evolution of the system, which begins with distribution and ends with distribution , is given by:
(60) |
where is the average heat flow from the system during the evolution of the system when the system starts in a state .
One can write the joint distribution as . When the variable is entirely ignored and the state of the system at a coarse-grained level is only specified by , it’s been shown that as long as the conditional distribution is constant, the heat flow at the coarse-grained level, defined as is well-defined [32]. In other words, when the system is in state , the distribution over the unobserved degree of freedom is constant. This could happen for example when is a fast degree of freedom and therefore it can be assumed to always remain in equilibrium. In such cases, it’s possible to define the EP at the coarse-grained level analogous to Eq. (60)
(61) |
where and are the marginal distribution of and , respectively, obtained by summing over . Above, is the net heat flow when the system starts with its state in .
Consequently, as long as the conditional distribution is constant [32], the mismatch cost formula (2) is well defined at the coarse-grained level and it could be used to lower bound the coarse-grained EP (61). Moreover, it has been shown in [32] that EP at a coarse-grained level consistently underestimates the EP calculated at a more detailed, finer level. In other words, EP at a coarse-grained level is always a lower bound on the calculated EP at a finer level. Therefore, applying the mismatch cost to coarse-grained variables establishes a lower bound on the EP of the underlying, finer-level physical process.
(62) |
This implies that, for any computational process, even when focusing solely on the computational variables and lacking detailed knowledge of the underlying physical variables involved, one can still evaluate the unavoidable EP using the mismatch cost.
Appendix C Lower bound on the worst-case mismatch cost
Consider the following cost function:
(63) |
The function is minimized at , which satisfies the condition (derived using the Lagrange multiplier method):
(64) |
which holds for all , where:
-
•
is the conditional probability from .
-
•
is the ending distribution, defined as .
Rewriting Eq. 64 as
(65) |
where . Using the constraint , we obtain:
(66) |
Note that is also the residual cost. Using the log-sum-exp inequality, we get:
(67) |
The formula for the mismatch cost is given by:
(68) |
where is the residual cost and is the distribution that minimizes the cost function. As discussed above, , given by Eq. 66. The cost function is a convex function (in case of a single island), so its maximum occurs at edge of the probability simplex. Let the corners of the simplex be denoted by , and define:
(69) |
Using the definition of the cost function, we have:
(70) |
The second term on the right-hand side is upper-bounded by . If the following condition is satisfied:
(71) |
for any other than , then the following holds true:
(72) |
which means that the maximizer of the cost function is located at the corner of the simplex where is maximum. Let us denote , where . When condition 71 is satisfied, the maximum value of the cost function is:
(73) |
(74) | ||||
(75) |
Applying the log-sum-exp inequality, we get:
(76) |
Further, we have:
(77) |
Since , when condition (71) holds, we find:
(78) |
where . Substituting this into Eq. 74, we obtain:
(79) |
(80) |
The last two sums can again be bounded by ,
(81) |
from which we obtain the final result
(82) |
Appendix D Mismatch cost calculations for Boolean circuits
Let us focus on a the state of the circuit when it is in the middle of the execution cycle. Let represent the state of the gate or the layer that is going to update its value based on the state of its parent . Let denote the state of the rest of the circuit not containing gate and the parents of . Updating the value of gate changes the state of the circuit,
(83) |
When a gate or a layer of gates in a circuit is updated based on the state of the parent gates (or parent layers) while the rest of the circuit remains unchanged, it constitutes a subsystem process [15]. In that case, the prior distribution of the process is a product distribution that has the following form:
(84) |
where . Mismatch Cost:
(85) |
The first KL divergence,
(86) | ||||
(87) |
The second KL divergence,
(88) | ||||
(89) |
Using chain rule for KL divergence, . Therefore,
(92) |
where is the drop in mutual information between the subsystem consisting of and and the rest of the system. Let’s calculate the drop in mutual information when the actual distribution over the state of the circuit changes according to (26),
(93) |
Since the initial distribution is , there is correlation between and , and between and . Therefore the mutual information decomposes into
(94) |
Note that contains the children of , and contains parents of . One can prove that . Therefore
(95) |
After updating , the distribution modifies to . The correlation between and is lost and at the same time new values of are correlated with . The mutual information is
(96) | ||||
(97) |
Therefore, the drop in mutual information is
(98) |
Hence, the mismatch cost when updates while rest of the circuit remains unchanged is
(99) |
The total mismatch cost of running the entire circuit with sequential gate-by-gate or layer-by-layer execution is the sum of subsystem mismatch cost. For a gate-by-gate run, the total mismatch cost is
(100) |
where
Appendix E RASP examples
E.0.1 Explanation of the code
We consider the RASP code of the main text:
1: LOAD x, R1 ; Load x into register R1 2: LOAD c, R2 ; Load c into register R2 3: CMP R1, R2 ; Compare the values in R1 and R2 4: JLE 7 ; If R1 <= R2, jump to line 7 5: SET R3, 1 ; Set R3 (a) to 1 if R1 > R2 6: JMP 8 ; Jump to the end of the program 7: SET R3, 0 ; Set R3 (a) to 0 if R1 <= R2 8: END End of the program
Below there is an explanation of each command. The command "LOAD x, R1“: This command loads the value of x (input) into the register R1. It prepares the value of x for comparison or further operations. The command “CMP x, c": This command compares the values of x and c. It sets the condition flags based on the result of the comparison (e.g., whether x is less than, equal to, or greater than c). The command “JLE b": This command stands for "Jump if Less than or Equal." If the comparison CMP x, c determines that x is less than or equal to c, the program counter jumps to line 6, skipping the next instruction. The command "SET a, c": If the condition from the comparison is not met (i.e., x is greater than c), this command sets the value of a to c. The command “JMP 7": This command is a jump instruction that ensures the program continues at line 7, preventing the following line from executing if the previous condition was true. Instead “END": This command signifies the halting of the execution.
E.0.2 State Transitions
The state transitions deterministically based on the current state and the operation specified by the current line of code. The transition rules are as follows:
-
1.
LOAD R1, x
(101) -
2.
CMP R1, 0
(102) -
3.
JG POSITIVE
-
•
If
(103) -
•
Otherwise
(104)
-
•
-
4.
JE ZERO
-
•
If
(105) -
•
Otherwise
(106)
-
•
-
5.
JL NEGATIVE
-
•
If
(107)
-
•
Example of State Transitions Consider the initial state where :
-
1.
LOAD R1, x
(108) -
2.
CMP R1, 0
(109) -
3.
JG POSITIVE
(110)