Simulating reversible computation with reaction systems

Reaction systems are a formal model of computation providing a framework for investigating biochemical reactions inside living cells. We look at the functioning of these systems as a process producing a series of different possible sets of entities representing states which can be changed by the application of reactions, and we study reversibility and its simulation in this framework. Our goal is to establish an Undo-Redo-Do-like semantics of reversibility with environmental control over the direction of the computation following a so-called no-memory approach, that is, without introducing modifications to the model of reaction systems itself. We first establish requirements the systems must satisfy in order to produce processes consisting of states with unique predecessors, then define reversible reaction systems in terms of reversible interactive processes. For such reversible systems, we also construct simulator systems that can traverse between the states of reversible interactive processes back and forth based on the input of a special “rollback” symbol from the environment.


Introduction
Natural computing is a research area concerned with computational models which may be either inspired by some natural phenomenon, or designed to help us better understand natural processes in terms of information processing [16,29].
Reversible computation is a paradigm extending the standard notion of the forwards-only mode of computation with the ability to be executed also in the reverse direction, such that computations can run backwards as naturally as they can run forwards. [20,22,30].
In this paper, we study reversibility and its simulation in the framework of reaction systems, a natural computational model by Ehrenfeucht and Rozenberg [12] aiming to provide a formal framework for investigating the biochemical reactions inside living cells. Computation in this model goes forward by applying reactions to a set of entities (called a state), creating a new set (a new state). The way this model works is also interactive in the sense that each state may also incorporate input, capturing the idea that living cells do not act in isolation but always operate in some environment which may influence their behavior (and thus, the computation). In contrast to previous results, such as those in [5], we aim to investigate how to introduce reversibility in reaction systems without losing its openness (its ability to incorporate input from the enclosing environment), and without making modifications on the model itself.
The rest of the paper is organized as follows. In Sect. 2 we discuss the main paradigms concerning the implementation of reversibility in the context of computational models of our interest. Sect. 3 comprises a concise introduction to the fundamental notions of reaction systems, then in Sect. 4 we present our notion of reversibility and provide necessary and sufficient conditions for reaction systems to be reversible. In Sect. 5 we show how to construct the "reverse" of a set of reactions, and then use these ideas to construct reaction systems which are able to simulate the forward and backward computations of reversible reaction systems. Finally, Sect. 6 ends the paper with some conclusions.

3 2 Paradigms of reversibility
Reversible computation is a field attracting interest from the points of view of several possible applications and much work is also devoted to establish its solid theoretical foundations. For more information on applications of reversibility, see the monograph [26], for a state-of-the-art survey of the area, see the recent collection [30].
A number of theoretical aspects of reversible computing have been studied over the years, see [6] for a survey summarizing recent results concerning categorical foundations of reversibility, foundations of programming languages and term rewriting, various models of sequential and concurrent computations, and addressing some of the challenges posed by quantum computation (which is in part also naturally reversible).
As reaction systems are biochemically inspired computational models, we would also like to mention some of the topics of reversible computation motivated by this area. In most of the cases, biochemical reactions are modeled by distributed systems of concurrent processes and this poses special types of questions with respect to their reversibility. Opposed to sequential processes (like the computations of Turing machines or most types of conventional automata) where the order of the execution of the computational steps can easily be reversed by undoing the last action, the definition of the backward execution of a collection of concurrently executing distributed processes is not straightforward at all, since there is no definite notion of the "last action" which should be undone first. To overcome this difficulty, the concept of causal-consistent reversibility was introduced in [10] as a suitable definition of reversibility for a concurrent scenario, which intuitively says that any action can be undone provided that all its consequences, if any, are undone already. Interestingly, besides the usual "backtracking" type and the more sophisticated causal-consistent type of reversibility, out-of-causal-order reversibility can also be defined, and as it may sound strange, it is important since it might make possible to get to states which cannot be reached by forward execution alone [27].
Another interesting aspect is the controlled vs. uncontrolled nature of reversibility. We speak of external control of reversible computation when some other process is in charge of controlling it by deciding whether it has to go backward or forward [18]. In Section 5 we will follow a similar approach when we present simulations of reversible reaction systems being able to switch between simulating forward or backward computations based on external input from the environment.
For a survey of causal consistent and controlled reversibility, see also [19].
As we already noted, biochemically inspired computational models, even when they are abstract and very much simplified, naturally include some kind of concurrency and parallelism appearing between its different possible computational processes. Suitable examples are membrane systems [24,25] which deal with multisets of symbols processed in the compartments of hierarchical structure of membranes according to some multiset rewriting rules: some of the symbols are changed in parallel according to the rules associated with their containing regions, while the others remain unchanged (and can be used in the subsequent steps) or get moved to other regions of the membrane structure. Concerning the reversibility of membrane systems, [1,2] defines it as a form of duality, while in [4] the reversibility of biochemical reactions in parallel rewriting systems are investigated (which can easily represent classes of models such as membrane systems, or Petri nets). In a more recent paper [28], membrane system configurations are enriched with a memory recording the information necessary for reversing steps.
The situation in the case of reaction systems, however, is different. Although, they are motivated by (and in a certain sense can also be used to model) biochemical processes, they represent a qualitative model. As opposed to systems being able to "count" by dealing with entities having multiplicities (as in multisets, for example), reaction systems deal with sets, which distinguishes them from the above mentioned models by (i) a threshold assumption: if a resource is present, it is always present in a sufficient amount necessary for any reaction; (ii) no permanency assumption: if an entity is not produced at a certain step, it will not be available for use at the next step [12]. As we will see later in more detail, such a way of functioning leads to a sequential model, very close in fact to finite transition systems (or finite automata). The concept of reversibility in the context of these types of computational models is rather straightforward. A model is reversible if it is "backward deterministic", that is if each of its computational configurations (or states) has at most one predecessor, or in other words, no state is accessible from two distinct states 1 . As simple as this definition is, it gives rise to different implementational paradigms among the actual models, some of which we will shortly review in the following. Our presentation is based mostly on [22,26].
As an automaton is reversible if it preserves information so that its computation can be retraced back in time [6], information preserving and reversibility are very closely related concepts. Landauer argued in [17] that any logical operation with information loss necessarily results in heat dissipated by the system performing the operation, and as there exist irreversible computations, he also claimed that there are computations where heat generation is inevitable. Inspired by these claims, Bennett created a universal reversible Turing machine, proving that irreversibility is not an inherent property of computation [8]. When constructing his model, he developed the so-called Compute-Copy-Uncompute paradigm, which comprises the following steps: The machine first performs a reversible forward computation, resulting in the desired output. Then, a copy is made from this output. Finally, the reverse execution of the forward steps (which is also reversible) cleans up the effects of the forward computation, leaving the original input and the copy of the corresponding output on the tapes. (See [26] for a more detailed and systematic treatment of this paradigm.) This result spawned extensive research interest in the field of reversible computing since it proved that reversible computing is the tool to overcome the performance constraints of traditional irreversible systems [13]. A more recent and rigorous treatment of reversibility concerning Turing machine computations can also be found in [7].
While the Compute-Copy-Uncompute paradigm fits the power consumption related study of reversibility well, it might be too static for others, since the outcome of the computation is of most importance, as opposed to the actual process of the computation itself. If we place our focus on the processes, however, we can discover another significant implication of reversibility: it allows for exploration and experimentation. Since every configuration has at most one predecessor, we can freely undo any previous computation and proceed by choosing a different computational route.
This very idea serves as the basis of the Undo-Redo-Do paradigm, depicted in Fig. 1. Below, we briefly describe the flow of computation in this paradigm, as discussed in [26].
-The Do operation corresponds to normal forward computation.
-At any state, we can choose to Undo our previous step, essentially reversing the execution, taking us back to the single predecessor of the current state. -Later, if we wish to recover our prior computation (thus, visiting the same states as before), we can perform a Redo. -Instead of recovering previous actions, if we want to experiment by taking a different route, we can dismiss any undone steps yet to be redone, and continue with a Do operation.
A similar approach was taken in [14] where reversible nondeterministic automata were investigated, and although in a different context, the idea of exploration and experimentation was also discussed in [11]. When considering reversibility in the case of (sequential) models with an emphasis on interaction with some external environment (such as reaction systems), the implementation of a paradigm like Undo-Redo-Do seems to be more suitable than, for example, Compute-Copy-Uncompute since it is well-aligned with the dynamic and exploratory characteristics of these models. Moreover, as we already mentioned, the process-focused nature of the paradigm (in contrast to the result oriented focus of Compute-Copy-Uncompute) also motivates its use in the following investigations.

Preliminaries
In what follows, we are going to briefly introduce the most important notions and notations concerning reaction systems. Our presentation is based on [9].
Reaction systems model biochemical reactions occurring inside a living cell. The intuition behind the model stems from the idea of facilitation and inhibition.
A reaction a is a triplet of three finite sets a = (R a , I a , P a ) . The set R a contains the reactants, I a contains the inhibitors, while P a consists of the products. The set of reactants and the set of inhibitors must be disjoint ( R a ∩ I a = � ) and the set of products must not be empty ( P a ≠ ∅).
If R a , I a , P a ⊆ S for some reaction a = (R a , I a , P a ) and finite set S, then a is a reaction over S. The set of all reactions over S is denoted by rac(S).
Intuitively, we can say that a reaction takes place if all of its reactants and none of its inhibitors are present. In such a case the reactants react, and the product set is created, just like in the case of biochemical reactions.

Remark 1
In what follows, if a is a reaction, then we will denote its components as R a , I a and P a without explicitly writing out the complete triplet form a = (R a , I a , P a ).
We also note that we use the symbols ⊆ and ⊂ to denote set inclusion and set inclusion in the strict sense (that is, when equality is excluded), respectively.
Given a set of entities (that can be arbitrary symbols) S and a reaction a ∈ rac(S) , we can always tell whether a can take place or not. For a finite set T ⊆ S , the reaction a is enabled by T, if R a ⊆ T and I a ∩ T = � . The result of a on T, denoted by res a (T) is defined as res a (T) = P a if a is enabled by T, or res a (T) = � if a is not enabled by T.
In the previous definitions, we only considered a single reaction. It is quite rare, however, that a single reaction can capture the behavior of a complex process. Consequently, the concepts above should be generalized to multiple reactions.
Let A be a finite set of reactions over a set of entities S, and let T ⊆ S be a finite set. Then en A (T) denotes the set of all reactions in A enabled by T, thus en A (T) = {a ∈ A | a is enabled by T} , and the result of A on T, denoted by res A (T) , is defined as res A (T) = ⋃ a∈A res a (T). The previous definition reflects two vital aspects of the model. Reactions can be enabled and applied even if their reactant sets overlap. Hence, there are no conflicts: each enabled reaction is allowed to produce its result. The results are also non-conflicting, which means that even if two or more reactions produce the same entity (because of intersections in their product sets), there will be no "multiple occurrences" in the result set. This qualitative nature comes from the fact that reaction systems use sets instead of multisets (these can be viewed as the quantitative counterparts of sets). Thus, in this model, an entity (which might be representing some chemical or biological resource) is either present in an amount that is sufficient or it is missing altogether.
In the following sections, we are going to work with finite sets of reactions. Therefore, we now introduce a shorthand notation for the reactants and products of these sets.

Notation 1 Let
A be a finite set of reactions. Then, we denote by R A and P A the union of the reactant sets and product sets, respectively: R A = ∪ a∈ A R a , P A = ∪ a∈ A P a .
We can further generalize the concept of enabled reactions and results, thus formalizing every possible enabled subset of reactions and the results of those.

Notation 2 Let
A be a finite set of reactions over the finite set S. We denote by EN A (S) the set that contains the sets of reactions which can be enabled simultaneously, that is, every E ⊆ A for which there exists a subset of S enabling every reaction in E. Formally In other words, EN A (S) contains the sets of reactions where the members of each set are simultaneously enabled for some subset S ′ of S. Here, we have since there is no set of elements such that a and c is enabled together (as R a ∩ I c ≠ �).
The elements of RES A (S) are the product sets produced by the reactions in the sets of EN A (S) applied to appropriate subsets of S, that is, Having established the most important notions, we can now recall the definition of a reaction system, which is an ordered pair A = (S, A) such that S is a finite set (called the background set) and A ⊆ rac(S) (called the set of reactions).

Remark 2 Given a reaction systems A = (S, A)
, we assume, without loss of generality, that A does not contain different reactions having the same set of reactants and the same set of inhibitors. (If a, a � ∈ A are reactions with a = (R, I, P 1 ) and a � = (R, I, P 2 ) , then they are always enabled and applied simultaneously, so they can be replaced by a single reaction (R, I, P 1 ∪ P 2 ) having the same effect.) Let A = (S, A) be a reaction system and let n ≥ 0 be an integer. An interactive process in A is a pair = ( , ) of finite sequences, such that The first few states of an interactive process are visualized in Fig. 2. Note that even though the figure shows the context set C i and the result set D i of the same state as non-overlapping rectangles, they do not have to be disjoint. The way interactive processes are defined has two significant consequences. An interactive process is finite since the prior choice of n determines its length. Thus, we can think of an interactive process as a finite state sequence. In this sequence, new states are created rather than transformed from the previous states. This leads us to the concept of no permanency: The next state is created from the products of the enabled reactions and the context set. Therefore, if an entity in the current state is not produced by any reaction and is not present in the next context set, then it will disappear. The intuition behind this idea comes from the realm of biochemistry where entities are produced and sustained by active, energy-consuming processes (not to be confused with our formal interactive processes). Thus, if there is no such process to sustain a given entity, then it will vanish. More information on the motivation behind this concept (and on reaction systems in general) can be found in [12].

Reversible reactions systems
We start by presenting a possible application of the concept of reversibility for the special case of reaction systems. Based on the discussions in Sect. 2, our aim is to interpret the notion of backward determinism in this framework. In reaction systems state sequences correspond to interactive processes, so we start by defining how the concept of unique predecessors can be applied to the states of interactive processes.

Definition 1 Let A = (S, A) be a reaction system and = ( , ) be an interactive process in
The interactive process is reversible, if every state W i , 1 ≤ i ≤ n , has a unique predecessor.
In the following, we will discuss the conditions that are necessary for obtaining reversible interactive processes. It is clear that if different reactions produce the same result, then we can arrive at the same state from different predecessor states. Moreover, since a state is the union of a context set and a result set, the property of having a unique predecessor does not only depend on the reactions and the results of the reactions, but also on the context sets which are added in each step of the interactive process. Even if every result set was unique, identical states could be created with wellchosen contexts. In order for an interactive process to be reversible, there must be at most one way to produce each context-result union, so the unique predecessor property of Definition 1 depends not only on the reactions of the system, but also on the context sets of the process. Since this dependency is rather involved, we are going to follow a step by step approach and introduce lemmas for describing the different requirements related to the reversibility of interactive processes.
First, let us consider the following. According to the general notion of reversibility, every state must have Fig. 2 The first four states of an interactive process = ( , ) in some reaction system a unique predecessor. Yet, when a given state does not enable any reactions, then the process continues with an empty result. We can then augment this empty result with a non-empty context, essentially restarting the process. Reversing execution from such an empty or restarting state would be equivalent to obtaining "something from nothing" which does not fit the concept of reversibility. Therefore, in what follows, we will only consider processes in which this restart does not occur.

Definition 2 Let
A be a reaction system and = ( , ) be an interactive process in A such that If the opposite holds, then is restarting.
, then (since the product sets of the reactions are We already noted that reversibility implies the uniqueness of result sets. This comes from the fact that regardless of the context, if there are multiple ways to produce the same set of entities, then it is not possible to recover the predecessor. If we consider the set W = {3, 4} , we can see that there are multiple subsets of reactions in A producing W, for example {a, b} and {c} . As a consequence, just by looking at W, we are unable to determine which reactions produced it. Equivalently, if W was a state in some interactive process, then this process would not be reversible, since we could not recover the predecessor of W. Deriving from the above example, we can impose the following requirement on the set of reactions. If we take every possible subset of reactions in which each reaction is enabled, then no two subsets should produce the same result. As the following lemma states, if the same result set is produced by two different enabled reaction sets, then there exists a state with multiple predecessors.  Proof Let A = (S, A) be a reaction system. Assume, that there exists E 1 , Thus, given some context set That being so, if W is a state in some interactive process, then W has multiple predecessors.
To see that such an interactive process always exists, Now, one might be tempted to conclude, that the assumption of Lemma 1 provides a sufficient condition for reversibility in the case of context-independent interactive processes (those with empty contexts except for C 0 ). Since there is a single reaction set producing every result set and the context is always empty (hence, W i = D i for all i ≥ 1 ), every state should have a unique predecessor. However, because of the no permanency assumption in reaction systems, this is not necessarily the case. According to the no permanency assumption, entities not sustained by at least one reaction will disappear, which can result in states with multiple predecessors even in context-independent interactive processes. Consider the sets W 1 = {0, 1, 2} and W 2 = {0, 1} . If we apply the reactions in A to these sets, we get 2} is a state in some context-independent interactive process, then W has multiple predecessors.
In the above example, the non-uniqueness of the predecessor was caused by a vanishing entity (the entity 2), one that was not a reactant of any of the enabled reactions. Given this observation, we might conjecture that the presence of entities not contained by the reactant sets of any of the reactions should imply the existence of states with multiple predecessors. The following example shows that this is not necessarily so. Consider the set W 1 = {0} . If we apply the reactions in A to W 1 , we get res A (W 1 ) = {0, 1} . Given this result set, we can deduce that the applied reactions were a and b, and can restore the original set W 1 .
Now, let us take the set W 2 = {0, 1} . Since the entity 1 is not a reactant of the reactions, it will disappear when any of the above reactions are applied. In this case, however, we can only apply a since 1 is an inhibitor of b, so we get res A (W 2 ) = {0} . Even though the element 1 has vanished because it was not sustained by any of the reactions, we can deduce its presence in the predecessor set of {0} because it inhibited the reaction b.
As the above example demonstrates, facilitation (being a reactant) is not the only thing that leaves a trace. Since inhibitors also affect the result of reaction application, we might be able to recover them from the result set. Thus, the presence of an entity which is not a reactant of any applied reaction in some state of an interactive process does not necessarily imply the existence of multiple predecessors. With this in mind, we can reformulate our previous observation: The "problematic states" are those, which contain entities whose presence or absence does not affect the set of enabled reactions. This is expressed in the following statement.
Lemma 2 Let A = (S, A) be a reaction system. If there exits a set T ⊆ S , en A (T) ≠ � , and an entity e ∈ T , such that then the there is a state W in some interactive process in A , such that W has multiple predecessors.
Proof Assume, that there exist T 1 ⊆ S , e ∈ T 1 , such that en A (T 1 ⧵{e}) = en A (T 1 ) , and let T 2 = T 1 ⧵{e} . This means, that res A (T 1 ) = res A (T 2 ) , so if W = res A (T 1 ) ∪ C is a state of an interactive process for some context set C ⊆ S , then T 1 ≠ T 2 , but both T 1 and T 2 are predecessors of W.
To see that such an interactive process always exists, is the initial context set. Then, since W 1 = res A (C 0 ) ∪ C 1 , the state W 1 in the interactive process is a state with multiple predecessors. ◻ The lemma above implies that whenever the same set of reactions is enabled by two or more different sets of entities, then there is a state with multiple predecessors in the corresponding interactive processes.   A = (S, A) be a reaction system. If there exist T 1 , T 2 ⊆ S , T 1 ≠ T 2 , such that en A (T 1 ) = en A (T 2 ) ≠ � , then there exists a state W in some interactive process in A such that W has multiple predecessors.

Corollary 1 Let
As we briefly noted, when discussing Definition 1, the notion of unique predecessor depends on both the reactions of the containing system and the context sets of the enclosing process. Given an appropriate set of reactions, it might still be possible to construct states with multiple predecessors, even if none of the above lemmas are applicable. To see this, consider the following. When assembling a new interactive process, we can make arbitrary choices regarding the elements of the contexts sets. Consequently, for every pair of distinct result sets, we can always choose an appropriate context set, so that the union of these sets will be equal. If the context sets can be arbitrary subsets of the background set (even the background set itself can be a context), then regardless of how well-chosen our reactions are, an appropriate context set can turn a state into one with multiple predecessors. Thus, we need to restrict which entities may appear in the contexts, or in other words, there have to be entities which cannot appear in any context set. To this aim, we write the background set S of a reaction system as the union of two not necessarily disjoint sets, the product alphabet Σ p ⊆ S (entities that appear in the product sets of the reactions) and the context alphabet Σ c ⊂ S (entities that can appear in the context sets). The model we obtain this way is similar to the one called context restricted reaction systems in [21].
Notice, however, that if restricting the sets of possible contexts, then there might be states which are not "reachable" in the sense that they cannot appear in any interactive process. necessarily disjoint) union of Σ p , the entities that are allowed to appear as products of reactions and Σ c , the entities that are allowed to appear in the context sets.

Definition 3 Let
A state W ⊆ S is reachable if there exists an interactive process W 0 , W 1 , … , W n in A with W = W i for some The following statement establishes a relationship between the properties of the reaction sets, the context alphabet, and the existence of states with multiple predecessors.

Lemma 3 Let A = (S, A) be a reaction system with
then there exists a state with multiple predecessors in some interactive process in A .
Proof Let A = (S, A) be a reaction system with S = Σ p ∪ Σ c . Assume that there exist R 1 , R 2 ∈ RES A (S) satisfying the conditions of the statement. As R 1 and R 2 are in RES A (S) , there exist W, T ⊆ S such that res A (W) = R 1 , res A (T) = R 2 , and W is a reachable state in A . (Note that W ≠ T , since given a fixed set of reactions, different result sets may only be created from different states.) Furthermore, since R 1 ≠ R 2 but R 1 ⧵Σ c = R 2 ⧵Σ c , if we choose the context set C as C = (R 1 ∩ Σ c ) ∪ (R 2 ∩ Σ c ) , then we have so there exist W, T ⊆ S , W ≠ T , and C ⊆ Σ c such that, for some state W ′ ⊆ S.
Since W is reachable in A , there is an interactive process , such that W ′ is a state in , and as To see the condition of the previous statement from a different point of view, we may also formulate it as follows.

then there exists a state with multiple predecessors in some interactive process in A .
Since computation in reaction systems is done using interactive processes, we can naturally formalize the definition of reversible reaction systems based on the reversibility of interactive processes.

Definition 4 A reaction system
A is reversible, if every nonrestarting interactive process in A is reversible.
Based on the lemmas above, we can formulate the necessary and sufficient conditions for the reversibility of a reaction system as follows.
Theorem 1 Let A = (S, A) be a reaction system with S = Σ p ∪ Σ c (where Σ p and Σ c are not necessarily disjoint).

The system A = (S, A) is reversible, if and only if the following conditions hold.
(1) For all E 1 , E 2 ∈ EN A (S) , Proof According to the Lemma 1, Corollary 1, and Lemma 3, no reaction system can be reversible if any of the above conditions does not hold.
To also see that the conditions imply the reversibility of a system, let us assume indirectly that there is a reaction system A = (S, A) (where S = Σ p ∪ Σ c ) which satisfies all three conditions of the theorem, but is not reversible. As A is not reversible, there is a non-restarting interactive process = ( , ) in A with sts( ) = W 0 , … , W n , where such that there is an i ≥ 1 for which W i has multiple predecessors, that is, with W ⊆ S , and C, C i ⊆ Σ c .
Since W ≠ W i−1 , we have en A (W) ≠ en A (W i−1 ) according to condition (2), and then P en A (W) ≠ P en A (W i−1 ) , that is, (1)

according to condition (1). Since W i−1 is reachable in A , condition (3) is applicable, which implies
This means that res A (W) and res A (W i−1 ) differ also in entities that are not in Σ c , therefore, there is no C, C � ⊆ Σ c such that which contradicts our assumption at (1), and thus completes the proof. According to Theorem 1, A is reversible as it satisfies all three conditions. In a reaction system satisfying the conditions of Theorem 1, every non-restarting interactive process is reversible, even in the presence of input from the environment in the form of context sets. Therefore, given any state of some nonrestarting interactive process, the predecessor of this state is unique and can be restored. Using this environmental input, however, one can only control the forward computation of the system. In the next section, we are going to extend these results so that the environment can also trigger backward computation.

Simulating reversible reaction systems
As discussed in Sect. 2, we believe that the Undo-Redo-Do paradigm fits well to the reversible variants of computational models with environmental interaction, as opposed to other, more static paradigms (such as Compute-Copy-Uncompute). The reversible reaction systems of Theorem 1, however, do not support this kind of controlled reversibility. To enable interactive environmental control over the direction of the computation inside a reaction system, we discuss in this section the interactive simulation of such systems. To this aim, we also need to be able to construct "reverse reactions", reactions which execute the backward computations of reversible reaction systems.
When creating simulating systems, we are going to make extensive use of interactive processes and consequently, finite sequences of sets. To ease notation, here we will introduce some new notations regarding such sequences.

Notation 3
Let W = W 0 , W 1 , … , W n be a finite sequence of n + 1 sets. Then -the length of W is denoted by |W|, -the reverse of W is denoted by ↼ W and is defined as For a finite set D, the finite sequence obtained by subtracting Dfrom each set in W is denoted by W⧵D , that is, For a finite sequence of sets For finite sequences of sets V 0 , V 1 , … , V n , n ≥ 0 , the finite sequence W obtained by concatenating these sequences is The intuition behind the simulator reaction systems is rather simple. If we take some interactive process in the simulator, then state sets of this process can be divided into one or more shorter subsequences. The first subsequence always represents a forward computation of the simulated system. Then, the second subsequence corresponds to a backward computation of the simulated system, undoing some actions previously computed by the first subsequence. Afterwards, another forward subsequence follows which is in turn equivalent to a series of Redo and Do operations. Backward computation does not occur by accident but is controlled by the environment using a special auxiliary symbol . When is present in the context, the simulator undoes its last computation, simulating a backward step of the original simulated system. This intuition is formalized in the following two definitions.

Definition 5 Let
A be a reaction system, = ( , ) be an interactive process in A , with = C 0 , C 1 , … , C n , = D 0 , D 1 , … , D n , and let ∈ S be a special entity in the background set. We say that the interactive process is a well-formed simulating interactive process if the following conditions hold for every 0 ≤ i ≤ n: The well-formedness of simulator interactive processes is a necessity, since cannot appear in the context arbitrarily. If a result set is empty or consists solely of entities from the context alphabet of the simulated system, then we have reached an initial state. In this case, backward computation makes no sense, as initial states lack predecessors. Additionally, if is present in the context, then regardless of any other input entity, a simulated backward step will take place. As only entities in the product alphabet of the simulated system influence the backward computation, any unnecessary context entity other than is forbidden. A = (S, A) and B = (S ∪ { }, B) be two reaction systems, with being an auxiliary symbol in the background set of B (forcing the system to compute a simulated backward step).

Definition 6 Let
The system B interactively simulates the interactive processes of A if the following conditions hold.
(1) For every interactive process in A , there is a well formed interactive process in B such that sts( ) = sts( ). -V 0 = sts( ) for some interactive process in A .
-If i = 2m for some m ≥ 1 , then there exists an interactive process in A such that V i ⊆ sts( ). -If i = 2m + 1 for some m ≥ 0 , then ∈ W for every W in V i and there exists an interactive process in A , such that According to the above definition, the simulating system can compute everything that the original simulated system is capable of computing (because of including all of its interactive processes), and, furthermore, the simulator can traverse back and forth among the states of the interactive processes of the simulated system. Backward computation is initiated by the auxiliary symbol . This notion of back and forth traversal is captured by the appropriate subdivision of the states of the interactive processes. Now, our goal is to show that the Undo-Redo-Do paradigm of reversibility can be achieved for reversible reaction systems using the above definition of interactive simulation. In what follows, we first show how to construct appropriate simulator systems and then prove that they adhere to the requirements of Definition 6. The intuition behind the constructions of the backward reactions of ↼ B can be summarized as follows. For each simultaneously applicable set of reactions E ∈ EN A (S) , the presence of the product set P E of E implies that a backward reaction produces the reactants of E, possibly together with the elements of DI A (S, E) in addition. The set DI A (S, E) contains those entities which might have also been necessary to make only the reactions of E simultaneously enabled by inhibiting other reactions which could have also been applied. This is how DI A (S, E) is constructed: It contains the inhibitors of those simultaneously applicable sets of reactions which have the same set of reactants as E, since these entities must have been present in the predecessor state (otherwise not E, but some other set of reactions would have been applied). There is also a set of inhibitors added to the backward simulating reactions, the set CONT A (S, E) , which is necessary, because there might be different sets of simultaneously enabled reactions E 1 , E 2 ∈ EN A (S) , such that P E 1 ⊂ P E 2 , that is, the product set of E 1 is a subset of the product set of E 2 . In this case, performing the reactions of E 1 backwards should only be possible if the elements of E 2 ⧵E 1 are not present. (The presence of these entities would indicate that state for which the predecessor should be produced was not the result of applying the reactions of E 1 , but the reactions of E 2 instead.) Based on Definition 7, the interactive undo-redo simula-torB = (S ∪ { }, B) interactively simulating A is constructed as follows.
Let Just as in the case of reversible reaction systems, we are going to take a step-by-step approach to prove that interactive undo-redo simulatorsystems constructed using Definition 7 are indeed interactive simulators in the sense of Definition 6. Taking an arbitrary well-formed simulating interactive process in a simulator system, we subdivide the state sequence of into smaller subsequences and for each subsequence of interest, we prove that it satisfies the appropriate condition of Definition 6.

Lemma 4 Let A be a reversible reaction system, let B be the interactive undo-redo simulatorof A , and and let be a well-formed simulating interactive process in B.
Then, the state sequence of can be written as sts( ) = V 0 V 1 , where V 0 is a finite sequence, such that V 0 ⧵{ } = sts( ) for some interactive process in A , that is, V 0 ⧵{ } is the state sequence of a forward computation of the simulated system A . Proof Let A = (S, A) ( S = Σ p ∪ Σ c ) be a reversible reaction system, let B be the interactive undo-redo simulatorconstructed from A using Definition 7, and let be a well-formed simulating interactive process in B with sts( ) = W 0 , W 1 , … , W n . Since is a well-formed simulating interactive process, there exists 0 ≤ m 0 ≤ n such that ∉ C i , 0 ≤ i ≤ m 0 . This means that starts with a finite sequence of states such that the length of this sequence is greater than or equal to one, and none of the sets in the sequence includes . Now we prove by induction on the value of m 0 that, given the previous condition, there exists an interactive process in A such that sts( ) = W 0 , W 1 , … , W m 0 when m 0 = n , or ∈ W m 0 +1 and sts( ) = W 0 , W 1 , … , W m 0 , W m 0 +1 ⧵{ } when m 0 < n . Thus, might be present in the (m 0 + 1) st context, nevertheless, with not taken into consideration, the state can still be part of some interactive process in A .
Given the well-formedness of , we can be sure that ∉ C 0 i.e. C 0 ⊆ Σ c . Hence, for the initial state W 0 = C 0 of there exists some interactive process in A sharing the very same initial state. Thus, for m 0 = 0 , the previous statement is true.
Assuming that the statement holds for an arbitrary m 0 = k , we now show that it also holds for m 0 = k + 1 . In this case, we know that there exists some interactive process in A such that sts( ) = W 0 , W 1 , … , W k . This implies that W k ⊆ S . Let us now enumerate the reactions applicable to this set. As ∉ W k , one can only apply reactions from ⇀ B , since takes the role of a reactant in every reaction of ↼ B . Note, that ⇀ B contains the very same reactions as A with a small difference: the inhibitor sets were augmented with . In our current case however, this role of is irrelevant, since ∉ W k . Consequently, we have that res A (W k ) = res B (W k ) = D k+1 . Thus, there exists some interactive process = ( , ) in A such that = D 1 , D 2 , … D k , D k+1 .
Let us now consider the context. As ∉ C k+1 we know that C k+1 ⊆ S . Since D k+1 ⊆ S and C k+1 ⊆ S we have that W k+1 ⊆ S and, in turn, there exists some interactive process in A such that sts( ) = W 0 , W 1 , … , W k+1 . We now continue by considering m 0 = k + 1 < n , meaning that the next state starts a new, simulated backward computation. In this case C m 0 +1 = { } . On the other hand, since we proved, that there exists some interactive process in A such that the state sequence of the process is equal to the sequence W 0 , W 1 , … , W m 0 , then it also holds, that extending this sequence with W m 0 +1 = res A (W m 0 ) ∪ { } , there exists some interactive process in A such that the state sequence of the process is equal to W 0 , W 1 , … , W m 0 , W m 0 +1 ⧵{ }.
This means, that the statement holds for m 0 = k + 1 which, in turn, renders our initial statement true. The argument above also implies that every interactive process in A is an interactive process in B as well, since both the C i context sets and the length k of the initial forward computing sequence can be chosen arbitrarily. ◻ Now we continue by showing that after the initial state sequence simulating a forward computation, the well-formed simulating interactive processes might continue with the simulation of backward computations.

Lemma 5 Let
A be a reversible reaction system, let B be the interactive undo-redo simulatorof A , and let be a wellformed simulating interactive process in B.
Then, the state sequence of can be written as sts( ) = V 0 V 1 , where V 0 ⧵{ } is the state sequence of a forward computation of the simulated system A , and V 1 can be written as V 1 = V 2 V 3 where V 2 is a finite sequence such that there exists some interactive process in A for which ↼ V 2 ⧵{ } ⊆ sts( ) . Thus, V 2 ⧵{ } is a state sequence of a backward computation of the simulated system A .
Proof Let A = (S, A) ( S = Σ p ∪ Σ c ) be a reversible reaction system, let B be the interactive undo-redo simulatorconstructed from A using Definition 7, and let be a well-formed simulating interactive process in B with sts( ) = W 0 , W 1 , … , W n = V 0 V 1 , where V 0 ⧵{ } is the state sequence of a forward computation of the simulated system A . Since V 0 is covered by Lemma 4, we know that there exists m 0 < n such that the finite sequence W 0 , W 1 , … W m 0 is the state sequence of some interactive process in A . In this case, for some m 0 < m 1 ≤ n , the well-formedness of implies that ∈ C i for m 0 + 1 ≤ i ≤ m 1 , and if m 1 < n , then ∉ C m 1 +1 . Now we prove by induction on the value of m 1 that there exists some interactive process in A for which the V 1 = W m 0 +1 , W m 0 +2 , … , W m 1 sequence is such that First, let us prove the statement for m 1 = m 0 + 1 , when the sequence consists of a single element. In this case, ∈ C m 1 and, implied by the proof of Lemma 4, there exists some interactive process in A such that Thus, for m 1 = m 0 + 1 , the statement holds.
Let us now assume, that the statement holds if m 1 = m 0 + k , and then prove that it also holds for m 1 = m 0 + k + 1 . We know that the state sequence Building on the previous facts, let us continue by defining W m 1 . Since ∈ W m 0 +k , only reactions in ↼ B can be applied to W m 0 +k (as the presence of forbids the application of reactions in ⇀ B ). A is reversible, therefore, no two reaction sets E 1 , E 2 ∈ EN A (S) produces the same result set. Thus, given an arbitrary result set D = P E for some E ∈ EN A (S) , we are able to restore W such that res A (W) = D . In order to do so, we take every reaction in E and create a new reaction with reactant set equal to D = P E and product set equal to W = R E . However, care should be taken, as there might be one ore more F ∈ EN A (S) reaction set such that P E ⊂ P F . If so, then elements not in P E must be forbidden by including every element in P F ⧵P E in the inhibitor set of the newly created reaction. This is exactly, how CONT A (E) is defined. That way, we will not end up falsely applying reactions because of the subset relationships. Our job is not done yet, however, since we must also consider inhibitors. As demonstrated in Example 4, inhibitors might also leave a trace by inhibiting some reactions and thus affecting the result. Hence, given the reactant set R E , we need to find reaction sets with the same reactants. Then, the inhibitors of the reactions in these sets should also be restored, since their presence denied the application of these reactions. Such inhibitor entities are captured by DI A (S, E) in Definition 7, and as a result, we will have a product set R E ∪ DI A (S, E).
Turning back to the definition of B , we can see, that reactions in ↼ B are constructed using this very method. What remains is, to find the reaction in ↼ B that can be applied to W m 0 +k . Such a reaction always exists and is always unique: unique, since A is reversible, which means that there is only a single way to produce every result set, and exists, since ↼ V 2 ⧵{ } ⊆ sts( ) for some interactive process in A , which means that the first set in ↼ V 2 ⧵{ } , that is, W m 0 +k ⧵{ } was surely produced from some state by applying some set of reactions in A. The only case in which the previous would fail is if W m 0 +k ⧵{ } was the initial state, however, this case is forbidden by the well-formedness of .
Concluding the previous reasoning, we have that the only reaction applicable to W m 0 +k is a uniquely determined reaction b ∈ ↼ B for which R b = W m 0 +k ⧵{ } holds. By applying this reaction to As a consequence, these states can be written as a sequence V 2 = W m 0 +1 , W m 0 +2 , … , W m 0 +k , W m 1 such that V ↼ 2 ⧵{ } ⊆ sts( ) for some interactive process in A (as V 2 is essentially an appropriate continuation of V 1 for which we already proved the same). This means, that the statement holds for m 1 = m 0 + k + 1 which, in turn, renders our initial statement true. ◻ Now we combine the previous two statements to obtain the following.

Lemma 6 Let
A be a reversible reaction system, let B be the interactive undo-redo simulatorof A , and let be a wellformed simulating interactive process in B , such that sts( ) = V 0 V 1 , where V 0 ⧵{ } is the state sequence of a forward computation of A , and -V 1 can be written as Then, if V 3 is not of zero-length, then subdividing V 3 into smaller subsequences will result in forward and backward computations of the simulated system A , analogous to those covered by Lemmas 4, 5.
Proof Let A = (S, A) ( S = Σ p ∪ Σ c ) be a reversible reaction system, let B be the interactive undo-redo simulatorconstructed from A using Definition 7, and let be a well-formed simulating interactive process in B with Since V 2 is covered by Lemma 5, we know that there exists m 0 < m 1 < n such that the finite sequence W m 1 ⧵{ }, W m 1 −1 ⧵{ }, … W m 0 +1 ⧵{ } is the state sequence of some interactive process in A . We now show that the proof for subsequent sequences in is analogous to the those of Lemmas 4, 5.
Now, because of the well-formedness of , we have that C m 1 = { } and ∉ C m 1 +1 . As a consequence of the former, we have that D m 1 +1 is the result of a simulated backward step, which means that res A (D m 1 +1 ) = W m 1 ⧵{ } . Also, W m 1 +1 = D m 1 +1 ∪ C m 1 +1 . As for the sequence V 4 = W m 0 +1 , W m 0 +2 , … W m 1 , D m 1 +1 , there exists some interactive process in A such that ↼ V 4 ⧵{ } ⊆ sts( ) , we have two possibilities regarding D m 1 +1 : -D m 1 +1 ⊆ Σ c , thus D m 1 +1 is equal to a restarting or initial state of , or -there exists some state W in such that D m 1 +1 ⧵Σ c = res A (W).
Regardless, the sequence V 5 = D m 1 +1 is contained within the sequence of states of . Since D m 1 +1 can only be extended with elements from Σ c to form W m 1 +1 then there is going to be an interactive process in A such that the sequence of states of contains W m 1 +1 . If we now apply the induction for forward computations (from Lemma 4), then we can say that given the subsequent contexts do not contain , then the newly started sequence of states is going to adhere Definition 6 (i.e. there exists some interactive process in A with an appropriate sequence of states containing this sequence). Now, if some C j context set contains , then we can apply the same induction as in Lemma 5, that is, starting from a set which is included within the state sequence of some interactive process in A , we can see that only valid backward steps can be simulated. Therefore, we have shown, that any further subsequence of is either a proper forward or backward computation of the simulated system A . ◻ Combining the three previous lemmas, we can state the following.
Theorem 2 For every reversible reaction system A , the interactive undo-redo simulatorconstructed from A using Definition 7 interactively simulates the interactive processes of A .
Proof Let A = (S, A) ( S = Σ p ∪ Σ c ) be a reversible reaction system, let B be the interactive undo-redo simulatorconstructed from A using Definition 7, and let be a wellformed simulating interactive process in B Given the previous assumptions, Lemmas 4, 5 and 6 can be applied. In these lemmas, by subdividing the state sequence of , we showed that satisfies the requirements of condition (2) in Definition 6. Since our choice of (apart from the well-formedness) is arbitrary, this also means that every well-formed interactive process in B satisfies the requirements of condition (2). When considering the first subsequence of in Lemma 4, we also showed, that wellformed interactive processes in B may start with any interactive process in A . Thus, for every interactive process in A we have an interactive process in B with the very same state sequence. Consequently B satisfies condition (1) in Definition 6.
This implies that B interactively simulates the interactive processes of A . ◻ Based on the above proof, we can construct an interactive simulator system (the interactive undo-redo simulator) for every reversible reaction system. The method of the construction is rather straightforward: First, we include a new symbol in the original background set and we create forward reactions by including in every inhibitor set. Then we assemble the backward reactions by enumerating the reaction sets which can ever become enabled (the elements of EN A (S) ) and follow the construction of Definition 7.
The simulators obtained that way may freely perform the forward and the backward computations of the original system, allowing for an Undo-Redo-Do-like semantics of reversibility where the environment has to control over the direction of the computation.

Conclusion
In this paper, we investigated the reversibility of reaction systems. This area was studied before by Aman and Ciobanu [5], however, in their work, they did not consider open interactive processes (processes with non-empty context sets) and they extended the model with features implementing a memory to remember vanished entities. We took a different approach by working with the model as-is (thus, adding no extensions) and allowing the use of non-empty context sets. We first identified the requirements which are necessary and sufficient for a reaction system to be reversible, then by showing how to build reverse reactions, we constructed simulator reaction systems which are able to simulate reversible reaction systems with their (forwards-only) computations in both directions, backwards and forwards.
As reversible reaction systems according to our notion of reversibility seem to be rather restricted, to study and determine the class of the possible computations which they can perform would definitely be of interest for further research. Since we expect that the class of possible computations are similarly restricted, some kind of relaxation of the unique-predecessor concept to arrive to a different, less restrictive notion of reversibility would also be of interest. One approach that we would like to explore in the future is a kind of "lookback" reversibility which is similar to the usual notion of backward determinism in automata. An automaton is backward deterministic (and thus, reversible) if the current state and the previously consumed input symbol together uniquely determine the previous state of the machine. A similar notion could be defined for interactive processes by noticing that the context sets play a similar role as the input symbols of automata, they are consumed by the actual step of the computation. According to the proposed reversibility concept, an interactive process would be reversible if the current state and the context set used in the previous step (to arrive to the current state) together uniquely determine the previous state of the process.