1 Introduction

Reversible computation allows computation to proceed not only in the standard, forward direction, but also backward, recovering past states, and computing inputs from outputs. Reversible computation has attracted interest for multiple applications, covering areas as different as low-power computing [113], simulation [37], robotics [122] and debugging [129]. However, such applications need to be supported by a clear understanding of the foundations of reversible computation. Over the years, a number of theoretical aspects of reversible computing have been studied, dealing with categorical foundations of reversibility, foundations of programming languages and term rewriting, considering various models of sequential (automata, Turing machines) and concurrent (cellular automata, process calculi, Petri nets and membrane computing) computations, and tackling also the challenges posed by quantum computation, which is in a large part naturally reversible. We report below on those threads of research, giving particular emphasis to the results obtained in the framework of the European COST Action IC1405 [78], titled “Reversible Computation - Extending Horizons of Computing”, which took place in the years 2015–2019 and involved researchers from 34 different countries.

The contents of this chapter are as follows. Section 2 covers category theory, Sect. 3 reversible programming languages, Sect. 4 term rewriting, and Sect. 5 membrane computing. We then discuss process calculi (Sect. 6), Petri nets (Sect. 7), automata (Sect. 8), and quantum verification and machine learning (Sect. 9). The chapter ends with a brief conclusion (Sect. 10).

2 Category Theory

Category theory is a framework for the description and development of mathematical structures. In category theory mathematical objects and their relationships within mathematical theories are abstracted into primal notions of object and morphism. Despite being a staple of the related field of quantum computer science for years (see, e.g., [3, 79, 174]), category theory has seen comparatively little use in modelling reversible computation, where operational methods remain the standard. While the present section aims to give an overview of the use of categorical models in providing categorical semantics for reversible programming languages, categorical models have also been studied for other reversible computing phenomena, notably reversible event structures [65].

2.1 Dagger Categories

One approach to categorical models of reversible computation is given by dagger categories, i.e., categories with an abstract notion of inverse given by assigning to each morphism \(X \xrightarrow {f} Y\) an adjoint morphism \(Y \xrightarrow {f^\dagger } X\), such that \((g \circ f)^\dagger = f^\dagger \circ g^\dagger \) and \(\mathrm {id}_X^\dagger = \mathrm {id}_X\) (that is, composition is respected) and \(f^{\dagger \dagger } = f\) for all compatible morphisms f and g. Note that this definition says nothing about how f and \(f^\dagger \) ought to interact. As such, \(f^\dagger \) is not required to “undo” the behaviour of f in any way, but can be any morphism with the appropriate signature, so long as the above constraints are met.

A useful specialisation of dagger categories, in connection with reversible computation, is dagger traced symmetric bimonoidal (or rig) categories, i.e., dagger categories equipped with two symmetric monoidal tensors (usually denoted \(- \oplus -\) and \(- \otimes -\)), interacting through a distributor and an annihilator, yielding the structure of a rig (i.e., a ring without additive inverses). Iteration is modelled by means of a trace operator \(\text {Tr}\) (see [1, 85, 175]) such that \((\text {Tr} f)^\dagger = \text {Tr}(f^\dagger )\). These categories are strongly related to the dagger compact closed categories [3, 174] that serve as the model of choice for the Oxford school of quantum computing.

The use of dagger traced symmetric bimonoidal categories to model reversible computations goes back at least as far as to the works by Abramsky, Haghverdi and Scott (see, e.g., [2, 4]) on (reversible) combinatory algebras, though its applications in reversible programming were perhaps best highlighted by the development of the \(\varPi \) and \(\varPi ^0\) calculi [34, 83]. In addition, the reversible functional programming language Theseus [82] exhibits a correspondence with the \(\varPi ^0\) calculus. However, dagger traced symmetric bimonoidal categories are not strictly enough to model \(\varPi ^0\), as such categories fail to account for the recursive data types formed using \(- \oplus -\), \(-\otimes -\), and their units. In his recent thesis, Karvonen [94] describes precisely the categorical features necessary for such a correspondence, which he calls traced \(\omega \)-continuous dagger rig categories.

Another notable application of this line of research is found in [167], where a reversible \(\varPi ^0\)-like language is extended to describe quantum computations without measurement, but with support for (necessarily terminating) primitively recursive functions.

2.2 Inverse Categories

Another approach to model reversible computation is inverse categories [95] (see [40] for a more modern presentation), a specialisation of dagger categories in which morphisms are required to be partial isomorphisms. More precisely, each morphism \(X \xrightarrow {f} Y\) may be uniquely assigned a partial inverse \(Y \xrightarrow {f^\dagger } X\) satisfying \(f \circ f^\dagger \circ f = f\).

The development of inverse categories as models of reversible computation was pioneered in the thesis of B.G. Giles [58], though a concrete correspondence was never provided. This work, combined with the comprehensive account of inverse categories with joins given in the thesis of Guo [67], was exploited in [86] to give an account of reversible recursion in inverse categories with joins.

Much of this theory was then put to use in [87], where the authors managed to show soundness, adequacy, and (under certain conditions) full abstraction for reversible flowchart languages [185] in a class of inverse categories with joins.

2.3 Monads and Arrows for Reversible Effects

The first account of monads pertaining to reversible computing was given in [71] as dagger Frobenius monads. Though these arise naturally in quantum computation in the context of measurement, it turns out that they are exceedingly rare in the case of classical reversible computing. A better concept for modelling and programming with reversible effects turns out to be that of dagger and inverse arrows [70], with examples such as reversible computation with mutable memory, errors and error handling, and more.

3 Foundations of Reversible Programming Languages

Reversible programming languages bridge the gap between the hardware and the specific application, and therefore play a central role in the development of reversible computing. Reversible languages must be expressive and usable in a variety of application domains. Their semantics must be precise and their programs accessible to program inversion, analysis and verification. Additionally, they must have efficient realisations on reversible devices and on standard ones. Recent programming language studies have advanced the foundations and theory of reversible languages in several interrelated directions.

3.1 Language Cores

Reversible languages have been reduced to their computational cores:

R-Core [63] is a structured reversible language consisting of a single command for reversible store updates, a single control-flow operator for reversible iteration, and data structures built from a single binary constructor and a single symbol. Despite its extreme simplicity, the language is reversibly universal, which means it is as computationally powerful as any reversible language can be. Its four-line program inverter is as concise as the one for Bennett’s reversible Turing machines. The core language and a recent extension with reversible recursion were equipped with a denotational semantics [61, 63, 64].

R-While [62] adds reversible rewrite rules and pattern matching as syntactic sugar to R-Core, which makes the family of structured reversible languages more accessible to foundational studies and educational purposes than do reversible Turing machines and other reversible devices. The procedural extension [64] draws a distinction between tail-recursion by iteration and general recursion by reversible procedures, a notoriously difficult transformation problem in program inversion [96, 151]. The linear-time self-interpretability makes the language also suitable for foundational studies of computability and complexity from a programming language perspective [84].

CoreFun [80] is a typed reversible functional language that seeks to reduce reversible functional programming [184] to its essentials so that it can serve as a foundation for modern functional language concepts. The language has a formal semantics and a type system to statically check for reversibility of programs.

3.2 Formal Semantics

Precise semantics is the foundation of every programming language, and formality is from where programming languages derive their usefulness and power.

A program is regarded as reversible if each of its meaningful subprograms is partially invertible. Thus, reversible programs have reversible semantics [61]. A foundation of the semantics has been established for structured reversible languages built on inverse categories [59, 60]. This class of languages includes Janus, a reversible language that was originally formalised by conventional (irreversible) operational semantics, and the R-Core and R-While languages. For example, predicates and assertions occurring in reversible alternatives and reversible iterations are modelled by decision maps, in contrast to conventional semantics. A benefit of the reversible semantic approach is that program inverters and equivalences of reversible programs can be derived directly from the semantics.

The assumption of countable joins in inverse categories is suitable in a categorical account of reversible recursion [86], which enables modelling of procedures in reversible structured and functional languages. Reversibility of Janus was proved with a proof assistant [153].

3.3 Compilation Principles

High-level languages are more productive in most application domains, but high levels of computational abstractions do not come for free. A clean and effective translation to lower abstraction levels is required and sophisticated optimisations may be necessary to generate high quality implementations.

Dynamic memory management is a central runtime mechanism to support dynamic data structures in reversible machines. Its purpose is to support reversible object-oriented languages as well as the core languages described above. Garbage collectors that use multiple references [142] to overcome linearity requirements and heap manager algorithms have been developed and experimentally evaluated. To ease the analysis and optimisation when translating from a high-level reversible language to the underlying reversible machine, the reversible single static assignment (RSSA) form can be a suitable intermediate representation in optimising compilers [141]. Its aim is to allow for advanced optimisations such as register allocation on reversible Von Neumann machines.

The recent languages Joule [173] and ROOPL [68] demonstrated that well-known object-oriented concepts can be captured reversibly by extending a Janus-like imperative language. Reversible data types [43], that is data structures with all of its associated operations implemented reversibly, are enabled by dynamic allocation of constructor terms on the heap [11]. A reversible dynamic memory management based on the Buddy Memory system [99] has been developed and tested in a compiler targeting the assembly language of a reversible computer [43].

3.4 Reversibilisation Techniques

A separate approach to reversibility is reversibilisation, which turns irreversible computations into reversible computations. This can be achieved by extending the semantics of an irreversible language or by instrumenting an irreversible program to continually produce information that ensures reversibility.

Some reversibilisation techniques work without user interaction, while others require annotation of programs. Techniques have been developed in recent years that add tracing to term rewriting systems [150] and instrument C++ programs with incremental state saving [171]. Other investigations have focused on techniques for debugging concurrent programs [121, 149] and on extending the operational semantics of an irreversible language with tracing [72], thereby defining the inverse semantics of the language. Hybrid approaches aim to combine reversibilisation and reversible sublanguages [172]. In general, the minimisation of the additional computational resources required for sealing information leaks by reversibilisation remains a central challenge.

4 Term Rewriting

Term rewriting [17, 98, 178] is a foundational theory of computing that underlies most rule-based programming languages. A term rewriting system (TRS) is specified as a set of rewrite rules of the form \(l \rightarrow r\) such that l is a nonvariable term and r is a term whose variables appear in l. Positions are used to address the nodes of a term viewed as a tree. A position p in a term t is represented by a finite sequence of natural numbers, where \(t|_p\) denotes the subterm of t at position p and \(t[s]_p\) the result of replacing the subterm \(t|_p\) by the term s. Substitutions are mappings from variables to terms.

Given a TRS \(\mathcal R\), we define the associated rewrite relation \(\rightarrow _\mathcal{R}\) as the smallest binary relation satisfying the following: given terms st, we have \(s \rightarrow _\mathcal{R} t\) iff there exist a position p in s, a rewrite rule \(l \rightarrow r \in \mathcal{R}\), and a substitution \(\sigma \) such that \(s|_p = l\sigma \) and \(t = s[r\sigma ]_p\). Given a binary relation \(\rightarrow \), we denote by \(\rightarrow ^{*}\) its reflexive and transitive closure, i.e., \(s \rightarrow ^*_\mathcal{R} t\) means that s can be reduced to t in \(\mathcal{R}\) in zero or more steps. The goal of term rewriting is reducing terms to so-called normal forms, where a term t is called irreducible or in normal form w.r.t. a TRS \(\mathcal R\) if there is no term s with \(t \rightarrow _\mathcal{R} s\). Computing normal forms can be seen as the counterpart of computing values in functional programming.

We also consider Conditional TRSs (CTRSs) of the form \(l \rightarrow r \Leftarrow s_1\twoheadrightarrow t_1,\ldots , s_n\twoheadrightarrow t_n\), with \(\twoheadrightarrow \) interpreted as reachability (\(\rightarrow _\mathcal{R}^*\)). Roughly speaking, \(s \rightarrow _\mathcal{R} t\) iff there exist a position p in s, a rewrite rule \(l \rightarrow r\Leftarrow s_1\twoheadrightarrow t_1,\ldots ,s_n\twoheadrightarrow t_n \in \mathcal{R}\), and a substitution \(\sigma \) such that \(s|_p = l\sigma \), \(s_i\sigma \rightarrow ^*_\mathcal{R} t_i\sigma \) for all \(i=1,\ldots ,n\), and \(t = s[r\sigma ]_p\). Consider, e.g., the following CTRS \(\mathcal{R}^\mathsf {fn}\):

where we use “\(\,:\,\)” and \([\,]\) as list constructors. Here, \(\beta _1\), \(\beta _2\) and \(\beta _3\) denote labels that uniquely identify each rewrite rule. Function \(\mathsf {fn}\) takes a list of persons of the form \(\mathsf {person}( first\_name , last\_name )\) and cities of the form \(\mathsf {city}( city\_name )\) and returns a list of first names. Note that it could be specified in a typical functional language (say, Haskell) as follows:

$$\begin{aligned}\begin{array}{l} \mathsf {fn}~[\,]= [\,]\\ \mathsf {fn}~((\mathsf {Person}~n~l)\!:\!xs) = n\!:\!ys ~~\mathsf {where}~ ys = \mathsf {fn}~xs\\ \mathsf {fn}~((\mathsf {City}~c)\!:\!xs) = ys ~~\mathsf {where}~ ys=\mathsf {fn}~xs\\ \end{array}\end{aligned}$$

4.1 Reversible Term Rewriting

In general, term rewriting is not reversible, even for injective functions; namely, given a rewrite step \(t_1 \rightarrow t_2\), we do not always have a decidable method to get \(t_1\) from \(t_2\). One of the first approaches to reversibility in term rewriting is due to Abramsky [2], who considered reversibility in the context of pattern matching automata.Footnote 1 Abramsky’s approach requires a condition called biorthogonality (which, in particular, implies injectivity), so that the considered automata are reversible. This work can be seen as a rather fundamental delineation of the boundary between reversible and irreversible computation in logical terms. However, biorthogonality is overly restrictive in the context of term rewriting, since almost no term rewrite system is biorthogonal. Another example of a term rewrite system with both forward and reverse rewrite relations is the reaction systems for bonding in [159]. It has been used to model a simple catalytic reaction, polymer construction, by a scaffolding protein and a long-running transaction with a compensation.

In the context of the COST action IC1405, Nishida et al. [148, 150] introduced the first generic notion of reversible rewriting, a conservative extension of term rewriting based on a so-called Landauer embedding. In this approach, for every rewrite step \(s \rightarrow _\mathcal{R} t\), one should store the applied rule \(\beta \), the selected position p, and a substitution \(\sigma \) with the values of some variables (e.g., the variables that occur in the left-hand side of a rule but not in its right-hand side). Therefore, reversible rewrite steps have now the form \(\langle s,\pi \rangle \rightharpoonup \langle t, \beta (p,\sigma ):\pi \rangle \), where \(\rightharpoonup \) is a reversible (forward) rewrite relation and \(\pi \) is a trace that stores the sequence of terms of the form \(\beta (p,\sigma )\). The dual, inverse relation \(\leftharpoondown \) is also introduced, so that its union \(\rightleftharpoons \) can be used to perform both forward and backward reductions.

Moreover, [148] also introduces a scheme to compile the reversible extension of rewriting into the system rules. Essentially, given a system \(\mathcal R\), new systems \(\mathcal{R}_f\) and \(\mathcal{R}_b\) are produced, so that standard rewriting in \(\mathcal{R}_f\), i.e., \(\rightarrow _{\mathcal{R}_f}\), coincides with the forward reversible extension \(\rightharpoonup _\mathcal{R}\) in the original system, and analogously \(\rightarrow _{\mathcal{R}_b}\) is equivalent to \(\leftharpoondown _\mathcal{R}\). Therefore, \(\mathcal{R}_f\) can be seen as an injectivisation of \(\mathcal{R}\), and \(\mathcal{R}_b\) can be seen as the inversion of \(\mathcal{R}_f\).

For instance, the injectivisation \(\mathcal{R}^\mathsf {fn}_f\) of the previous CTRS \(\mathcal{R}^\mathsf {fn}\) is as follows:

$$\begin{aligned}\begin{array}{ll} \mathsf {fn^i}([\,]) \rightarrow \langle [\,],\beta _1 \rangle \\ \mathsf {fn^i}(\mathsf {person}(n,l)\!:\!xs) \rightarrow \langle n\!:\!ys,\beta _2(l,ws) \rangle \Leftarrow \mathsf {fn^i}(xs) \twoheadrightarrow \langle ys,ws \rangle \\ \mathsf {fn^i}(\mathsf {city}(c)\!:\!xs) \rightarrow \langle ys,\beta _3(c,ws) \rangle \Leftarrow \mathsf {fn^i}(xs) \twoheadrightarrow \langle ys,ws \rangle \\ \end{array}\end{aligned}$$

together with the corresponding inversion \(\mathcal{R}^\mathsf {fn}_b\):

$$\begin{aligned}\begin{array}{ll} \mathsf {fn^{-1}}([\,],\beta _1) \rightarrow [\,]\\ \mathsf {fn^{-1}}(n\!:\!ys,\beta _2(l,ws)) \rightarrow \mathsf {person}(n,l)\!:\!xs \Leftarrow \mathsf {fn^{-1}}(ys,ws) \twoheadrightarrow xs\\ \mathsf {fn^{-1}}(ys,\beta _3(c,ws)) \rightarrow \mathsf {city}(c)\!:\!xs \Leftarrow \mathsf {fn^{-1}}(ys,ws) \twoheadrightarrow xs\\ \end{array}\end{aligned}$$

For example, the following rewrite derivation in \(\mathcal{R}^\mathsf {fn}\):

$$ \begin{array}{l} \mathsf {fn}([\mathsf {person}(\mathsf {john},\mathsf {smith}),\mathsf {city}(\mathsf {london}), \mathsf {person}(\mathsf {ada},\mathsf {lovelace})]) \rightarrow ^*~ [\mathsf {john},\mathsf {ada}] \end{array} $$

is now as follows in \(\mathcal{R}^\mathsf {fn}_f\):

where \(\beta _2(\mathsf {smith},\beta _3(\mathsf {london},\beta _2(\mathsf {lovelace},\beta _1)))\) is the trace of the computation. Besides proving some fundamental properties of reversible rewriting, Nishida et al. [150] have developed a prototype implementation of the reversibilisation transformations (injectivisation and inversion), which is publicly available through a web interface from http://kaz.dsic.upv.es/rev-rewriting.html.

4.2 Application to Bidirectional Transformations

The framework of bidirectional transformations considers two representations of some data and the functions that convert one representation into the other and vice versa (see, e.g., [75] for an overview). Typically, we have a function called “\(\mathsf {get}\)” that takes a source and returns a view. In turn, the function “\(\mathsf {put}\)” takes a possibly updated view (together with the original source) and returns the corresponding, updated source. In this context, bidirectionalisation [128] aims at automatically producing one of the functions, typically producing a function \(\mathsf {put}\) from the corresponding function \(\mathsf {get}\). For this purpose, a so-called complement function is often introduced so that \(\mathsf {get}\) becomes injective (see, e.g., [55]).

In [152], Nishida and Vidal present a bidirectionalisation technique based on the injectivisation and inversion transformations of CTRSs from [150]. They also prove a number of relevant properties which ensure that changes in both the source and the view are correctly propagated and that no undesirable side-effects are introduced.

To be precise, given a \(\mathsf {get}\) function f, the corresponding \(\mathsf {put}\) can be automatically defined as follows:

Note that the trace of a computation, \(\pi \), plays the role of a complement (following the terminology in the literature of bidirectional transformations).

For instance, given the previous function \(\mathsf {fn}\), the corresponding put function is defined as follows:

so that, e.g., \(\mathsf {put_{fn}}([\mathsf {peter},\mathsf {ada}], \beta _2(\mathsf {smith},\beta _3(\mathsf {london},\beta _2(\mathsf {lovelace},\beta _1))))\) reduces to \([\mathsf {person}(\mathsf {peter},\mathsf {smith}),\mathsf {city}(\mathsf {london}), \mathsf {person}(\mathsf {ada},\mathsf {lovelace})]\). Note that the first element has been updated from \(\mathsf {person}(\mathsf {john},\mathsf {smith})\) to \(\mathsf {person}(\mathsf {peter},\mathsf {smith})\).

However, \(\mathsf {put_f}\) is only defined for “compatible” view updates. E.g., the function \(\mathsf {put_{fn}}([\mathsf {ada}], \beta _2(\mathsf {smith},\beta _3(\mathsf {london},\beta _2(\mathsf {lovelace},\beta _1))))\) cannot be reduced to a value. In [152], the use of narrowing [76, 176]—an extension of rewriting that replaces matching with unification—is introduced to precisely characterise compatible (also called in-place) view updates.

For example, given the trace \(\beta _2(\mathsf {smith},\beta _3(\mathsf {london},\beta _2(\mathsf {lovelace},\beta _1)))\), narrowing allows us to compute the view skeleton \([x_1,x_2]\). This means that any view update that can be obtained as an instance of \([x_1,x_2]\) is compatible with the trace (and, thus, the put function is well defined).

Finally, [152] also discusses some directions for dealing with view updates that are not compatible.

5 Membrane Computing

Natural computing is a complex field of research dealing with models and computational techniques inspired by nature that helps us in understanding the biochemical world in terms of information processing. Membrane computing [154] and reaction systems [53] are two important theories of natural computing inspired by the functioning of living cells.

Membrane computing deals with multisets of symbols processed in the compartments of a membrane structure according to some multiset rewriting rules; some of the symbols (presented with their multiplicity within the regions delimited by membranes) evolve in parallel according to the rules associated with their membranes, while the others remain unchanged and can be used in the subsequent steps. It is also possible to send multisets of symbols in the neighbouring membranes, the systems being organised in a tree-like fashion. The evolution takes place in a maximal parallel manner: all the instances of the applicable rules have to be applied in order to reach the next state.

The situation is different in reaction systems. These systems represent a qualitative model: they deal with sets rather than multisets. Two major assumptions distinguish the reaction systems from the membrane systems: (i) threshold assumption: reaction systems have actually an infinite multiplicity for their resources; (ii) no permanency assumption: only entities produced at one step will be present in the system at the next step.

The issue of reversibility in various computational paradigms has gained interest in recent years. In one of the earliest papers on reversibility in membrane systems [5], the authors (under the influence of category theory) presented reversibility as a form of duality. A full description of this kind of reversibility in membrane systems is given by Agrigoroaiei and Ciobanu in [6].

In [7], Aman and Ciobanu investigated the reversibility of biochemical reactions in parallel rewriting systems; these systems can easily represent some classes of membrane systems and Petri nets. Formally, a parallel rewriting system is a tuple \((O,{\mathcal {R}},w_0)\), where O is a finite alphabet of objects, \({\mathcal {R}}\) is a set of rewriting rules and \(w_0\) is a multiset of objects over O. For each rule \(r \in {\mathcal {R}}\) there exist the non-empty multisets \(lhs(r), rhs(r) \in O^+\) standing for the left-hand side and right-hand side of the rule, respectively, such that \(r: lhs(r) \rightarrow rhs(r)\). Given a multiset of rules F, then the left-hand side and right-hand side of it can be defined as: \(lhs(F)=\sum _{r\in {\mathcal {R}}}F(r)\cdot lhs(r)\) and \(rhs(F)=\sum _{r\in {\mathcal {R}}}F(r)\cdot rhs(r)\).

A parallel rewriting system \((O,{\mathcal {R}},w_0)\) evolves in a maximal parallel manner. This means that a non-empty multiset R of rules is applicable to a multiset w of objects if \(lhs(R)\le w\) and there does not exist \(r\in {\mathcal {R}}\) such that \(lhs(r) \le w-lhs(R)\). By applying a multiset R of rules, a multiset w of objects is transformed into another multiset \(w'=w-lhs(R)+rhs(R)\) of objects. If no multiset of rules is applicable, then the computation stops.

The new features of this approach are given by adding an external control specified by using a special symbol \(\rho \notin O\) that informs the system that a rollback will be executed, and by constructing two new sets of rules \(\overrightarrow{{\mathcal {R}}}=\{u \rightarrow v|_{\lnot \rho } \mathrel {\big |} u \rightarrow v \in {\mathcal {R}}\}\) and \(\overleftarrow{{\mathcal {R}}}_{\rho }=\{ v \rightarrow u|_{\rho } \mathrel {\big |} u \rightarrow v \in {\mathcal {R}}\} \cup \rho \rightarrow \lambda \) to mark the rules that will be applied in forward and backward steps, respectively.

Several theoretical results are obtained, including the so-called loop results and the connections between the evolutions of these systems and their reversible extensions. If there exist multisets of rules not competing for the same resources, then the following results hold.

A first result presents the forward diamond property:

If \(w\xrightarrow {\overrightarrow{{\mathcal {R}}}} w'\) and \(w\xrightarrow {\overrightarrow{{\mathcal {R}}'}} w''\), where \(\overrightarrow{{\mathcal {R}}}\) and \(\overrightarrow{{\mathcal {R}}'}\) are two valid multisets of rules such that \(lhs(\overrightarrow{{\mathcal {R}}}) \cap lhs(\overrightarrow{{\mathcal {R}}'}) = \emptyset \), then there exists a multiset \(w_1\) such that \(w' \xrightarrow {\overrightarrow{{\mathcal {R}}'}} w_1\) and \(w'' \xrightarrow {\overrightarrow{{\mathcal {R}}}} w_1\).

The second result presents the reverse diamond property:

If \(w \xrightarrow {\overleftarrow{{\mathcal {R}}_{\rho }}} w'\) and \(w \xrightarrow {\overleftarrow{{\mathcal {R}}'_{\rho }}} w''\), where \(\overleftarrow{{\mathcal {R}}_{\rho }}\) and \(\overleftarrow{{\mathcal {R}}'_{\rho }}\) are two valid multisets of rules such that \(lhs(\overleftarrow{{\mathcal {R}}_{\rho }}) \cap lhs(\overleftarrow{{\mathcal {R}}'_{\rho }}) = \emptyset \), then there exists a multiset \(w_1\) such that \(w' \xrightarrow {\overleftarrow{{\mathcal {R}}'_{\rho }}} w_1\) and \(w'' \xrightarrow {\overleftarrow{{\mathcal {R}}_{\rho }}} w_1\).

A forward step performed using the multiset \(\overrightarrow{{\mathcal {R}}}\) of rules can be matched by a backward step performed using the multiset \(\overleftarrow{{\mathcal {R}}_{\rho }}\) of rules, and vice-versa (loop):

$$w \xrightarrow {\overrightarrow{{\mathcal {R}}}} w' \quad \text { if and only if } \quad \rho w' \xrightarrow {\overleftarrow{{\mathcal {R}}_{\rho }}} w.$$

In [8], Aman and Ciobanu investigated reversibility in reaction systems. Reaction systems [53] deal with sets rather than multisets, assuming that each resource is present in the system in a sufficient amount to ensure that several reactions needing such a resource are not in conflict. Formally, a reaction system \({\mathcal A}\) is a tuple (SA), where S is a finite alphabet and \(A \subseteq rac(S)\). The set \(rac(S)=\{ (R, I, P) \mid R,I,P \subseteq S, R \cap I = \emptyset \}\) is the set of all reactions over S. Given a reaction \(a = (R_a, I_a, P_a)\), the sets \(R_a\)\(I_a\) and \(P_a\) contain the reactants, inhibitors and products of a, respectively. For a set \(C \subseteq S\) and a set of reactions \(A \subseteq rac(S)\), the result of applying A on C is defined by \(res(A,C ) = \bigcup _{a \in A} P_a\), and the evolution can be written as \(C \xrightarrow {A} res(A, C)\). The set of all reactions from A that are enabled by C is \(en(A,C) = \{a \in A \mid R_a \subseteq C, I_a \cap C = \emptyset \}\).

An interactive process is a pair \(\pi = (\gamma , \delta )\) such that \(\gamma =C_0, \ldots , C_{n-1}\), \(\delta = D_1, \ldots , D_n\) with \(n \ge 1\), where \(C_{j-1}\), \(D_{j} \subseteq S\) for \(1\le j\le n\) are the context and result sets, respectively. The sets \(D_j\) are computed using the equalities \(D_1 = res(A,W_0)\) and \(D_i = res(A,W_{i-1})\), where the sets \(W_0=C_0\) and \(W_i=D_i \cup C_i\) for each \(2\le i\le n\) represent the states.

In order to have backward computations, we add to each state \(W_i\) a register \(T_i\) to remember objects no longer available after step i. The reverse of a set A of reactions is the set \(\tilde{A}=\{ (P_a,I_a,R_a) \mid (R_a,I_a,P_a)\in A\}\). If \(\rho \not \in W_i\) and \(E_i \ne \emptyset \), then a forward computation \((W_i,T_i) \xrightarrow {E_i} (W_{i+1}, T_{i+1})\) takes place, where \(T_{i+1} = inc(T_i) \cup \; \bigcup _{t \in W_i\backslash lhs(E_i)} (t,0)\), \(inc(T) = \bigcup _{(t,i)\in T}(t,i+1)\) and \(W_{i+1} = res(E_i,W_i)\). However, if \(\rho \in W_i\) and \(\tilde{E_i}\ne \emptyset \), then a backward computation \( (W_{i+1}, T_{i+1}) {\mathop {\rightsquigarrow }\limits ^{\tilde{E_i}}} (W_i,T_i)\) takes place, where \(T_i = dec(T_{i+1})\), \(dec(T_d) = \bigcup _{(t,i)\in T_d; i>0}(t,i-1)\) and \(W_i = res(\tilde{E_i},W_{i+1}) \cup \; zero(T_{i+1})\) with \(zero(T) = \bigcup _{(t,0)\in T}t\).

If the states satisfy some preconditions, then backward reductions are the inverse of the forward ones, and vice-versa:

  • If \(W=res(\tilde{E},W') \cup zero(T')\) and \(\rho \in W'\), then

    $$(W,T) \xrightarrow {E} (W',T') \text { implies } (W',T') {\mathop {\rightsquigarrow }\limits ^{\tilde{E}}} (W,T).$$
  • If \(W'=res(E,W)\) and \(\rho \not \in W\), then

    $$(W',T') {\mathop {\rightsquigarrow }\limits ^{\tilde{E}}} (W,T) \text { implies } (W,T) \xrightarrow {E} (W',T').$$

An operational correspondence between reaction systems and rewriting theory is also proved. It allows a translation of the reversible reaction systems into some rewriting systems executable in the rewriting engine Maude [39].

In [163] Pinna pursues reversibility in membrane systems from a different perspective. The paper focuses on how to reverse steps in computations of membrane systems, without adding rules to represent the reverse application of the original rules. Just one assumption on rules is made, namely that rules are not allowed to rewrite a multiset of objects into an empty multiset: the application of a rule must have an effect, though this could be not observable. This requirement is driven by the necessity that, in order to reversely apply a rule, this one must produce something. Furthermore, as in most rewriting systems, also in the considered membrane systems a computation step does not register the (multiset of) rules applied. Since this information may be crucial to reversely apply the same (multiset of) rules, one needs some strategies to solve the issue and obtain reversibility.

A solution can be to enrich each object with the information on how the particular object has been produced, namely each object now may carry the name of the rule r used to produce it. Objects are then \(O\times R\cup \{\bot \}\) where R is the set of rules \(\bigcup _{i} R_i\), with i ranging over the membranes, and \(\bot \) denotes that the object is present in the initial configuration. The unique assumption is that rule names are unique. The drawback of this solution is that once an object is used the information on how it has been produced is lost.

To overcome this problem, the proposed solution is to add to the notion of configuration, previously a vector of multiset of objects, with one element for each membrane, a memory organised as a labelled partial order. Each element of the partial order corresponds to an object and carries also the information on which rule produced it. According to this a memory \(\mathsf {m}\) is a triple \((X, \preceq , l)\) where \(\preceq \) is a partial order and \(l : X \rightarrow O\times R\cup \{\bot \}\times \{1, \dots ,n\}\) is the labelling associating the object, the name of rule that produced it and the membrane where the object is allocated. A configuration of a membrane system with n membranes is then the pair \(\mathcal {C} = (C,\mathsf {m})\), where \(C = (w_1, \dots , w_n)\) is the tuple of multisets over objects O and \(\mathsf {m} = (X, \preceq , l)\) is a memory such that for each \(i\in \{1, \dots , n\}\) it holds that \(w_i = \mathsf {obj}_i( max (\mathsf {m}))\), where \( max \) gives the multiset of maximal elements of the memory and \(\mathsf {obj}_i\) forgets the information about the rule.

The effect of applying a vector of multisets of rules \(\mathcal {R}\) does not consist only in updating suitably the multisets of objects forming a configuration in the classical sense, but also in adding the information on which rule produced a specific object in the memory. This will be denoted with \((C,\mathsf {m}) \{\![\mathcal {R}\!> (C',\mathsf {m}')\) where \(C {\mathop {\,}\limits ^{\mathcal {R}}}{\Longrightarrow }\, C'\) is the usual step in membrane systems computation and the new memory \(\mathsf {m}'\) is obtained adding to \(\mathsf {m}\) the objects produced by the rules in \(\mathcal {R}\) and by updating the partial order so that the produced elements are greater than the ones consumed by these rules.

Then the reverse application of a vector of multisets of rules can be obtained by looking in this memory for the maximal elements, which correspond to the right-hand sides of the rules to be reversely applied. The proper configuration is then computed from the new memory obtained by removing the maximal elements. The reverse application of a vector of multisets of rules \(\mathcal {R}\) is denoted with \((C,\mathsf {m}) <\!\mathcal {R}]\!\} (C',\mathsf {m}')\), where the maximal elements of \(\mathsf {m}'\) corresponding to the right-hand sides of rules in \(\mathcal {R}\) are removed obtaining a memory \(\mathsf {m}\) and a configuration C where each element \(w_i = \mathsf {obj}_i( max (\mathsf {m}))\).

The following result has been proved:

Let \(\varPi _m\) be a membrane system with memory, \((C,\mathsf {m})\) a configuration, and \(\mathcal {R}\) be a vector of multisets of rules such that \((C,\mathsf {m})\{\![\mathcal {R}\!>(C',\mathsf {m}')\). Then, for all multi-rule vectors \(\mathcal {R}'\) such that \((C',\mathsf {m}')<\!\mathcal {R}]\!\}(C,\mathsf {m})\), it holds that \(\mathcal {R}' = \mathcal {R}\).

This simple implementation has the advantage of properly realising the causal reversibility. Furthermore the memory allows also to capture the dependencies among objects in a membrane system computation.

6 Process Calculi

Process calculi are a class of algebraic models for concurrent and distributed systems. Process calculi allow one to express the behaviour of a concurrent system in a concise way, abstracting away from implementation details, and focusing on the interaction patterns among the components of the system. Thus, it is possible to express the behaviour of a system in a mathematically precise way and verification techniques can be easily developed on top of it.

Research on reversing process calculi can be perhaps tracked back to the Chemical Abstract Machine [30], a calculus inspired by chemical reactions whose operational semantics defines both forward and reverse reduction relations. The first attempts to reverse existing process calculi can be found in [44, 46], where a reversible extension of CCS [140] was presented. A main contribution of [44] was the definition of the notion of causal-consistent reversibility: any action can be undone, provided that its consequences, if any, are undone first. This definition is tailored to concurrent systems, where actions may overlap in time, hence saying “undo the last action” is not meaningful. Notably, this definition relates reversibility to causality instead of time, thus it can be applied even in those settings, such as some distributed systems, where no unique notion of time exists. A survey on causal-consistent reversibility can be found in [120].

6.1 Reversing Process Calculi

Following [44], causal-consistent extensions of other and more expressive process calculi have been defined. They can be divided into two families, one dealing with calculi equipped with labelled transition system semantics (describing interactions between the process and the outside world), and one dealing with reduction semantics (describing the evolution of processes in isolation). The former is more general, while the latter is normally simpler and hence more easily applicable to expressive calculi. The first approach extended causal-consistent reversibility from CCS to any calculus defined using a specific SOS format (a subset of the path format [146]) [160, 161], and to \(\pi \)-calculus [42]. In the second line of research we find extensions of a fragment of CCS with biological relevance [35, 36], of the higher-order \(\pi \)-calculus [117, 119], of the coordination language Klaim [56], of a \(\pi \)-calculus with sessions [179], and of a CCS with broadcast communications [133]. The instance of the framework in [160] on CCS is called CCSK. CCSK differs from the reversible CCS in [44] in the way history is kept. Indeed, the approach of [160] can be considered static, since the structure of processes does not change during computation, and the minimal history information needed to enable reversibility is kept in the processes themselves, while in [44] the process is consumed during execution (as standard in process calculi) and larger memories are added to store history information. Nonetheless the two methods are equivalent as hinted at by [130] and fully proved by [115], where a mapping from an instance on CCS of [160] to the reversible CCS of [44] and vice versa is presented.

As discussed above, causally-consistent reversibility relates reversibility with causality. In CCS just one main notion of causality exists, and both the reversible variants of CCS above are based on it. In the \(\pi \)-calculus, many relevant notions of causality exist, which differ in the treatment of parallel extrusions of the same name. In [131] a uniform framework to define reversible \(\pi \)-calculi is presented. The framework is parametric w.r.t. a data structure that stores information about extrusions of a name. Different data structures yield different approaches to the parallel extrusion problem, leading to different ways of reversing a name extrusion, thus giving rise to different reversible variants of the \(\pi \)-calculus.

Fig. 1.
figure 1

Example of causal-consistent (left) and out-of-causal order reversibility (right)

6.2 Controlled Reversibility

The line of research described above focused on uncontrolled reversibility, defining how to reverse a process execution (in particular, which history and causal information is needed, and how to manage it), but not specifying when and whether to prefer backward execution over forward execution or vice versa. Uncontrolled reversibility allows one to understand how reversibility works, but not to exploit it into applications. Indeed, different application areas need different mechanisms to control reversibility. For instance, in biological systems the direction of the computation depends on physical conditions such as temperature and pressure, while in reliable systems reversibility is used to recover a consistent state when a bad event occurs. Triggered by these needs different mechanisms for controlling reversibility have been proposed (see the categorisation in [118]). For instance, [45, 179] introduced irreversible actions to avoid going backward after a relevant result has been computed. Instead, [56, 57, 114, 116, 118, 126] proposed an explicit rollback operator undoing a past action inside calculi where normal computation is forward, and a mechanism of alternatives allowing one to avoid trying the same path again and again. As shown in [57], the rollback operator satisfies a simple intuitive specification, namely that it is the smallest causal-consistent sequence of backward moves undoing the target action. Also, [18] let an energy potential drive the direction of computation while [158] introduced a forward monitor controlling the direction of execution of a reversible monitored process. A process calculus with a prefixing operator to model locally-controlled reversibility is introduced in [102, 103]. Actions can be undone spontaneously, as in other reversible process calculi, or as pairs of concerted actions, where performing a weak action forces the undoing of a past action. Concerted actions allow one to model out-of-causal order computation, where effects can be undone before their causes, which is forbidden in most other reversible calculi. This form of reversibility is common in biochemical reactions, e.g., in the hydration of formaldehyde in water into methanediol. Such a feature can be disabled by considering a reduced form of concerted actions.

Reversibility, both in causal order and out-of-causal order, can be modelled in reversible event structures [157].

Figure 1 shows the difference between causal-consistent (left) and out-of-causal order reversibility. In both cases, the system performs actions a, b and c to reach state D. On the left, in order to get back to the original state, one has to first undo (in Fig. 1 undoing is represented with squiggly arrows) c then b and finally a. On the right, since causes do not need to be respected, the system can undo b before c, reaching in this way a new state E which may not have been reachable from the initial configuration by just using forward steps. From there, a and c may or may not be undoable. In the example, only c can be undone, leading to \(B'\). If undoing b and undoing c do commute, then \(B = B'\).

6.3 Analysis Techniques

Despite the proliferation of calculi for reversibility, when the COST Action IC1405 started, analysis techniques for reversible calculi were very limited, consisting essentially in some limited analysis about behavioural equivalences (in particular, forward-reverse bisimilarity [161]) and a technique for causal compression in CCS with irreversible actions [101]. Thus, the work in the COST Action tackled analysis techniques in depth, considering behavioural equivalences, contracts [77] and session types [77].

Behavioural Equivalences. Understanding which notions of behavioural equivalences are suitable for reversible process calculi is a non-trivial, and still open, problem.

As shown in [119], notions of weak bisimilarity that do not distinguish forward actions from backward actions are very coarse, while notions of strong bisimilarity distinguishing them, such as forward-reverse bisimilarity [161], are very fine-grained, hence other notions are worth exploring.

In [135] Mezzina and Koutavas studied testing preorders, and in particular a safety one and a liveness one, in a reversible CCS where reductions are totally ordered and rollbacks lead systems to past states. Liveness and safety in this setting correspond to the should-testing [166] and inverse may-testing preorders [50] for the underlying forward calculus, respectively. In general, one would expect the models of these preorders to be based on both forward and backward transitions, thus offering complex proof techniques for verification. Instead, in [135] full abstraction of liveness and safety is based only on forward transitions and limited rollback points, giving rise to considerably simpler proof techniques. Moreover, total reversibility allows one to make finer observations w.r.t. liveness, but not w.r.t. safety.

Contracts. (Binary) contracts are a behavioural model [77] to study the interactions between a client and a server. The first investigation of contracts in a reversible setting appeared in [21, 22]. There, both the client and the server could rollback to a previous checkpoint at any moment. The main result was that the compliance relation, ensuring that the client and the server can successfully interact, and the sub-behaviour relation, are both decidable, and they remain so also when the possibility of skipping some messages is added.

In retractable contracts [23, 24] the client and the server can both get back to previous decision points and take alternative paths only when the interaction is stuck. The main results in [23, 24] are that retractable contracts are a conservative extension of contracts, both compliance and the subcontract relation are decidable in polynomial time, and the dual of a contract always exists and has a simple syntactic characterisation. Furthermore, retractable contracts are equivalent to a novel model of contracts featuring a speculative choice: all the options of the choice are explored concurrently, and the computation succeeds if at least one of the options is successful. In [20], a three-party game-theoretic interpretation of retractable session contracts [23] has been proposed. In such an interpretation a client is compliant with a server if and only if there exists a winning strategy for a particular player in a game-theoretic model of contracts. Such a player can be looked at as a mediator, driving the choices in the retractable points.

Session Types. Session types [77] are one of the formalisms that have been proposed to structure interaction and reason over communicating processes and their behaviour. In a series of works [136,137,138] reversible monitored semantics for binary [136, 138] and multiparty [137] session types is investigated. The novelty of the approach is that monitors are derived by types, and they store all the needed information to bring the system back to previous states. This implies that processes of the system are oblivious to reversibility, as they do not store any information about past computations. A deeper discussion on session types and reversibility can be found in [134].

7 Petri Nets

Petri nets [165] are a mathematical formalism for modelling and reasoning on concurrent systems. In most of the cases, Petri nets are four-tuples containing two finite sets, of active (actions/transitions) and static (places) elements, which are connected by a flow function (or relation) with initial state given by tokens scattered on places. In what follows, by Petri net we mean its most common variant, called place-transition net.

Petri nets support both action-based and state-based approaches (via reachability graphs which are equivalent to transition systems). Reversibility in Petri nets was always an important notion, however its meaning changed in time. At first, in the seventies, the notion of reversibility referred to nets where each transition has its inverse [54]. Such a notion of local reversibility is very close to the one currently used in other fields, like programming languages or process calculi. This notion of reversible nets (also called symmetric nets [54]) is still occasionally used to define the inverse net [33]. The time complexity of some decision problems in bounded symmetric Petri nets is lower than in the general case of bounded nets. The other meaning of reversibility in Petri nets, also called cyclicity [33], takes a global approach and requires the initial state of the net to be reachable from any other reachable state [147]. Petri nets are called symmetric also in other situations than the described local notion of reversibility [41].

During the four years of the COST Action IC1045, “Reversible Computation - Extending Horizons of Computing”, the notion of local reversibility was investigated. One can divide the proposed contributions into three main threads: two of them consider how to reverse a single transition in a Petri net, allowing one to use, respectively, a single reverse transition or a set of reverses. The last thread focuses on modelling reversible semantics in specific models based on Petri nets.

An approach to invert a single transition using a single (strict) reverse was investigated under both the sequential semantics and the true concurrent semantics. The case of sequential semantics was considered in [28]. The strict reverse is added to the net as a fresh transition with arcs copied from the original one, but with the opposite direction. The problem of checking whether the set of reachable markings in a net changes, when a strict reverse for a single transition is added, was proven to be undecidable. The opposite result was shown for the set of all coverable markings. Another important fact shown in [28] is related to cyclicity: introducing a strict reverse in a cyclic net may change the set of reachable markings.

The above problem of checking whether the set of reachable markings in a net changes by adding a strict reverse for a single transition becomes decidable for the bounded nets. Therefore, one can ask a more general question - is it possible to reverse the specified transition while only requiring the resulting net and the given one to have isomorphic behaviour (i.e., isomorphic reachability graph), but allowing one to change the structure of the net? The question has been answered by using well-known techniques from region theory [19]. There are transition systems which are reachability graphs of a bounded Petri net where transitions cannot be inverted by strict reverses, but one can easily combine separate solutions for different transitions to solve the problem [26]. Even in the special case of linear transition systems over binary sets of actions the transitions cannot be always inverted by strict reverses. In such systems, the time complexity of the problem of checking whether the set of reachable markings changes by adding a strict reverse for a single transition is linear [48]. Another special case of bounded nets are occurrence nets, that is 1-safe and acyclic nets without backward conflicts, where one can always use strict reverses. This property of occurrence nets and their infinite extensions was used as an intermediate step in [132], described later on.

Another line of research on strict reverses considers systems under concurrent semantics of action execution. In such systems one can execute more than one action at the same time, including the situation when a single action is executed multiple times (auto-concurrence). Reversing atomic transitions in such systems is discussed in [49]. In simple cases, where auto-concurrence is excluded, one can reduce reversing under the concurrent semantics to the sequential case. However, in the case of true multisets of actions executed simultaneously, one needs to allow mixed reverses (i.e., steps where both forward and backward actions are present) and true concurrent reversing can be reduced to coping with all spikes (i.e., multisets of actions with singleton support).

In a more general setting, in order to invert a single transition, one can allow to define a set of reverses with the opposite effect, called effect reverses [26]. In such a case, the problem of finding a bounded Petri net where each transition can be reversed and with isomorphic behaviour becomes always solvable [26]. Hence, some systems where inverting transitions using strict reverses was impossible become reversible in this setting. Moreover, the price to make any bounded net ready for inverting by the sets of effect reverses is not high - one needs to transform the original net into its complementary version, which doubles the size of the set of places [26].

A similar attempt for unbounded nets is presented in [139]. There are unbounded nets which cannot be inverted even using infinite sets of effect reverses for their transitions. However, if it is possible, then finite sets are enough. The problem of finding a possibly totally different net with isomorphic behaviour that can be reversed was reduced to extending the existing one by new places which do not disable any transitions in any reachable state and checking whether there exists a pair of problematic states. Those pairs of problematic states are strongly structured, with a natural partial order. The set of all minimal pairs of problematic states for a given system is finite, however, the problem of checking whether two given states form a problematic pair is not elementary, while the problem of checking whether there exists at least one such pair is undecidable [139].

A different line of research considers extensions of Petri nets with causal-consistent local reversibility [132]. Such an extension can be obtained for any place transition net by unfolding it into occurrence nets and folding them back to a coloured Petri net with an infinite number of colours. Those colours are used to encode the content of a stack used to reverse the computation. The price to be paid is that coloured Petri nets with infinitely many colours are in general Turing complete.

Another approach to investigate causal-consistent local reversibility, but also out-of-order local reversibility, is the biologically inspired model of reversing Petri nets [155]. There tokens are persistent bases connected by bonds which are relocated by transitions of the net. The greatest limitation of the approach is the requirement of finiteness and acyclicity of the net modelled in this way. On the other hand, one can encode reversing Petri nets into coloured Petri nets with a finite number of colours [27], hence also into classical bounded place-transition systems. Moreover, reversing Petri nets were successfully applied to the distributed antenna selection problem [156].

Petri net theory has been deeply studied. Cyclic and symmetric systems play quite an important role, however the issue of equipping concurrent systems with reversing mechanisms was not explored. The research conducted as a part of the COST Action IC1405 “Reversible Computation - Extending Horizons of Computing” enriched the theory of Petri nets by exploring some approaches to reverse transitions in existing systems. Although the effect of adding reverses of the actions to the existing system is in general difficult to evaluate (the problem of behaviour preservation is undecidable for place-transition nets), the problem can be solved if one allows unbounded stacks (coloured Petri nets approach) or restricts oneself to bounded models.

8 Automata

Automata theory studies abstract machines, or automata, as mathematical models of computation. They help in understanding limits of computation and the role of various resources – such as time and space – on the computational power. Examples of widely studied classes of automata include finite automata (bounded memory), pushdown automata (infinite memory organised as a stack), counter machine (infinite memory organised as counters), Turing machines (infinite memory tape) and cellular automata (massively parallel regular network of finite automata). These come in several flavours and variations, e.g., with respect to determinism. An automaton is reversible if it preserves information so that its computation can be retraced back in time. All the automata classes above can support reversibility. See [105, 143] for details on computation by various models of reversible automata.

8.1 Finite Automata

Reversibility in finite automata has been widely investigated, e.g., [9, 162]. The class of languages having a reversible one-way automaton is a proper subclass of the regular one. However, different models have been considered, depending on whether automata are required to have only one initial state and/or only one final state. Languages not having any reversible classical automaton have been characterised in terms of a forbidden pattern in the minimum automaton [73]. In the same paper, an NL-complete method to decide whether the language accepted by a given deterministic finite automaton can also be accepted by some reversible deterministic finite automaton has been derived.

In case the language accepted by a deterministic finite automaton is reversible, the size of the smallest reversible automaton may be exponential with respect to the size of the minimal irreversible one [73]. Recently analyses about the descriptional complexity of reversible deterministic finite automata provided some techniques to simulate these devices in an efficient way [123, 125]. Indeed, though converting a deterministic automaton into a reversible one may require an exponential increase in size, the proposed representation allows to limit this cost by concisely representing the reversible automaton rather than explicitly writing down its description.

Based on the forbidden pattern approach, the degree of irreversibility for a regular language has been studied [13]. The degree is defined to be the minimal number of such forbidden patterns necessary in any deterministic finite automaton accepting the language. It is shown that the degree induces a strict infinite hierarchy of language families. The behaviour of the degree of irreversibility under the usual language operations union, intersection, complement, concatenation, and Kleene star, has been studied, showing tight bounds (some asymptotic) on the degree.

Because of the narrowness of the power of reversible finite automata with respect to the irreversible ones, the definition of reversibility has been relaxed, by considering finite automata whose computations can be reversed, at any point, by accessing the last k symbols read from the input, for a fixed k. These devices are said to be “weakly irreversible”. Characterisations of languages accepted by weakly irreversible automata and languages not having any weakly irreversible automaton (“strongly irreversible” languages) have been given [124].

Another treatment of a relaxed definition of reversibility concerns nondeterminism. It turned out that reversible nondeterministic finite automata are more powerful compared to their reversible deterministic counterparts, but still cannot accept all regular languages [74]. The two notions of relaxed reversibility have been compared and closure properties of the language family induced by these devices have been derived.

8.2 Pushdown Automata

Reversible classical pushdown automata have been introduced in [107]. Their computational capacity turned out to lie properly in between the regular and deterministic context-free languages. In the same paper, it is shown that a deterministic context-free language cannot be accepted reversibly if more than real-time is necessary for acceptance. Closure properties as well as decidability questions for reversible pushdown automata are studied and it is shown that the problem to decide whether a given nondeterministic or deterministic pushdown automaton is reversible is P-complete, whereas it is undecidable whether the language accepted by a given nondeterministic pushdown automaton is reversible.

One extension of finite automata in order to enlarge the underlying language class as well as to preserve many positive closure properties and decidable questions is represented by input-driven pushdown automata. Such automata share many desirable properties with finite automata, but still are powerful enough to describe important non-regular behaviour. Basically, for such devices the operations on the pushdown store are determined by the input symbols. With respect to reversibility they have been studied in [110]. So, the sub-family of the context-free languages that share the two important properties of being accepted by an input-driven pushdown automaton as well as of being accepted by a reversible pushdown automaton are considered. This intersection can be defined on the underlying language families or on the underlying machine classes. It turned out that the latter class is properly included in the former. The relationships between the language families obtained in this way and to reversible context-free languages as well as to input-driven languages are studied. In general, a hierarchical inclusion structure within the real-time deterministic context-free languages is obtained. Finally, the closure properties of these families under the standard operations are investigated and it turned out that all language families introduced are anti-AFLs (that is, they are not closed under any of the operations required to be an Abstract Family of Languages).

Since reversible finite automata do not accept all regular languages and reversible pushdown automata do not accept all deterministic context-free languages, it is of significant interest both from a practical and theoretical point of view to close these gaps. Therefore these reversible models have been extended by a preprocessing unit which is basically a reversible injective and length-preserving sequential transducer [16]. It turned out that preprocessing the input using such weak devices increases the computational power of reversible deterministic finite automata to the acceptance of all regular languages. On the other hand, for reversible pushdown automata the accepted family of languages lies strictly in between the reversible deterministic context-free languages and the real-time deterministic context-free languages. Moreover, it has been derived that the computational power of both types of machines is not changed by allowing the preprocessing sequential transducer to work irreversibly.

Two-pushdown automata where the input is placed in one pushdown and that perform computations by inspecting and rewriting words at the top of the pushdowns are of particular interest as the deterministic variant is known to characterise the class of Church-Rosser languages when the rewriting is length-reducing. Such reversible two-pushdown automata are studied in [14]. A separation of the deterministic and reversible variants are obtained as well as the incomparability with the (deterministic) context-free languages. However, their properties of emptiness, (in)finiteness, universality, inclusion, equivalence, regularity, and context-freeness are not even semi-decidable.

8.3 Finite State and Pushdown Transducers

Computational models are not only interesting from the viewpoint of accepting some input, but also from the more applied perspective of transforming some input into some output. Transductions that are computed by different variants of transducers are studied in detail in the book of Berstel [31].

Reversibility in transducing devices has been investigated recently in [47, 111] for deterministic finite state transducers. In [111], the families of transductions computed are classified with regard to three types of length-preserving transductions as well as to the property of working reversibly. It is possible to settle all inclusion relations between these families of transductions even with injective witness transductions. Furthermore, the standard closure properties and decidability questions have been investigated. It turned out that the non-closure under almost all operations can be shown, whereas all decidability questions can be answered in polynomial time. Finally, the strict concept of reversibility is relaxed and an infinite and dense hierarchy with respect to the grade of reversibility is obtained.

Deterministic pushdown transducers have also been introduced, and analysed with respect to their ability to compute reversible transductions [66]. Now, the families of transductions computed are classified with regard to four types of length-preserving transductions as well as to the property of working reversibly. It turns out that accurate to one case separating witness transductions can be provided. For the remaining case it is possible to establish the equivalence of both families by proving that stationary moves can always be removed in length-preserving reversible pushdown transductions.

8.4 Queue Automata and Limited Automata

A further natural and well-studied extension of finite automata are queue automata, where the extension is by a storage media of type queue. Their reversible variant has been studied in [109]. In contrast to, for example, finite or pushdown automata, it has been shown that any queue automaton can be simulated by a reversible one. So, reversible queue automata are as powerful as Turing machines. Therefore it is of interest to impose time restrictions on queue automata. Quasi real-time and real-time computations have been considered. It has been shown that every reversible quasi real-time queue automaton can be sped up to real-time. On the other hand, under real-time conditions reversible queue automata are less powerful than general queue automata. Furthermore, a lower bound of \(\varOmega \left( \frac{n^2}{\log (n)}\right) \) time steps for real-time queue automata witness languages to be accepted by any equivalent reversible queue automaton has been exhibited. The closure properties of reversible real-time queue automata are similar as for reversible deterministic pushdown automata. Moreover, all commonly studied decidability questions such as emptiness, finiteness, or equivalence are not semi-decidable for reversible real-time queue automata. Furthermore, it is not semi-decidable whether an arbitrary given real-time queue automaton is reversible.

A k-limited automaton is a linear bounded automaton that may rewrite each tape square only in the first k visits, where \(k\ge 0\) is a fixed constant. It is known that these automata accept context-free languages only. The deterministic k-limited automata have been investigated towards their ability to perform reversible computations [112]. It turned out that, for all \(k\ge 0\), sweeping k-limited automata accept regular languages only. In contrast to reversible finite automata, all regular languages are accepted by sweeping 0-limited automata. Then the computational power gained in the number k of possible rewrite operations has been studied. It has been shown that the reversible 2-limited automata accept regular languages only and, thus, are strictly weaker than general 2-limited automata. Furthermore, a proper inclusion between reversible 3-limited and 4-limited automata languages has been obtained. The next levels of the hierarchy are separated between every k and \(k+3\) rewrite operations. Finally, it turned out that all k-limited automata accept Church-Rosser languages only, that is, the intersection between context-free and Church-Rosser languages contains an infinite hierarchy of language families beyond the deterministic context-free languages.

8.5 Cellular Automata

A cellular automaton (CA) is a dynamical system on an infinite grid of cells defined by a local update rule that is applied simultaneously at all cells. More precisely, in the usual rectilinear d-dimensional setting the cells are the elements of \(\mathbb {Z}^d\) and each cell stores an element of a finite state set A. The dynamics is specified by a finite neighbourhood \(D\subseteq \mathbb {Z}^d\) that gives the relative offsets to neighbours of cells, and a local rule \(f:A^D\longrightarrow A\) that gives the new state of a cell based on the previous states in its neighbourhood. A configuration \(c:\mathbb {Z}^d\longrightarrow A\), specifying the global state of the system, changes in a single time unit to become the new configuration \(c'\) with \(c'(\vec {n})=f(\sigma ^{\vec {n}}(c)_{|D})\) for every cell \(\vec {n}\in \mathbb {Z}^d\), where \(\sigma ^{\vec {n}}\) denotes the shift map that translates the configurations so that cell \(\vec {n}\) moves to the origin.

By carefully choosing the update rule f, the global dynamics \(c\mapsto c'\) can be made information preserving. In this case, an inverse cellular automaton retraces the computation back in time, and the cellular automaton is called reversible (RCA). See [90] for a recent survey on reversible cellular automata. Cellular automata have an important role as providing simple models in microscopic physics, and because of time-reversibility of microscopic dynamics the cellular automata models are also typically reversible [181]. Reversible cellular automata are able to carry out universal computation [180], even in the one-dimensional setting [144].

In the symbolic dynamics nomenclature reversible cellular automata are called automorphisms of the (full) shift. By Hedlund’s theorem [69] cellular automata are precisely the transformations \(A^{\mathbb {Z}^d}\longrightarrow A^{\mathbb {Z}^d}\) of the configuration space that commute with shifts \(\sigma ^{\vec {n}}\) and that are continuous under the compact prodiscrete topology on \(A^{\mathbb {Z}^d}\). Reversibility then just means that the transformation is a bijection, i.e., a homeomorphism. Automorphisms form a group under composition, and the structure of the automorphism group of the full shift (as well as of its subshifts) is a topic of active research [168]. For example, it is not known if the groups of one-dimensional RCA over two states and over three states are isomorphic with each other.

Decision Problems. Decision problems concerning reversibility and related properties have been extensively studied. There are efficient algorithms to test one-dimensional cellular automata for reversibility [177] while in higher dimensional cases reversibility is undecidable [88]. It is also undecidable, even in the one-dimensional case, whether a given RCA is periodic [92], that is, whether some iteration of the CA amounts to the identity function. Periodicity among one-sided RCA is not known to be decidable or undecidable at this time, where one-sidedness refers to the property that the neighbours to the left of a cell have no influence on its next state, nor on the previous state given by the inverse automaton. Periodicity in the one-sided case remains an active research topic due to its link to the finiteness problem of groups generated by Mealy automata [51].

Two dynamical systems are called conjugate if there is a homeomorphism between them that maps orbits to orbits. Conjugate systems are essentially identical. It is undecidable if two given cellular automata are conjugate [81]. This is true even for one-dimensional cellular automata, but if the considered CA are reversible then the undecidability is known in the two- and higher dimensional cases only.

Physical Universality and Glider Automorphisms. A cellular automaton is called physically universal if it can implement any transformation of patterns on any finite domain of cells by suitably choosing the initial states outside the domain. There are reversible cellular automata that are physically universal [170], even in the one-dimensional setting [169]. These automata (reversibly) break the input pattern into fleets of gliders that scatter out of the finite domain. Symmetrically, the inverse automaton breaks the desired output pattern into fleets of inverse gliders. The task of the surrounding gadget is to change the first fleet into the second fleet to implement the desired transformation.

Glider automorphisms that decompose finite configurations into fleets of gliders have been studied in more general subshifts, and they have found applications in understanding the structure of the automorphism groups [100].

Reversible Cellular Automata and Mahler’s Problem in Number Theory. If real numbers are written in base pq for some co-primes p and q then there is no carry propagation when numbers are multiplied by constant p. This means that multiplying by p is a local operation, that is, a reversible cellular automaton. Composing such reversible cellular automata yields, for example, an RCA for multiplying numbers in base 6 by constant 3/2.

Mahler’s problem asks whether there exists some positive real number \(\xi \) such that the fractional part of \(\xi \left( \frac{3}{2}\right) ^n\) is less than 0.5 for all positive integers n [127]. So the fractional part of the number should remain below one half no matter how many times the number is multiplied by 3/2. The problem is still unsolved. The problem has a very simple interpretation in terms of the RCA that multiplies by 3/2 in base six [89], and using this link it has been proved that for arbitrarily small \(\varepsilon >0\) there is a number \(\xi >0\) and a finite union \(U\subseteq [0,1)\) of intervals of total length \(\varepsilon \) such that the fractional parts of all \(\xi \left( \frac{3}{2}\right) ^n\) are in U [91]. The dynamical property of expansivity of the associated reversible cellular automaton plays a central role in the proof. Conversely, there is also a finite union \(V\subseteq [0,1)\) of intervals of total length \(1-\varepsilon \) that does not contain the fractional parts of all \(\xi \left( \frac{3}{2}\right) ^n\) for any \(\xi >0\).

Asynchronous Updating. In an asynchronous cellular automaton (ACA) only some cells are updated simultaneously. In the one-dimensional setting, one possibility is that states are updated sequentially during a left-to-right (or right-to-left) sweep across the entire infinite line of cells. Such a setup is studied in [93] where the update performed once in each position is given by a reversible block rule \(A^n\longrightarrow A^n\) on n consecutive cells. The authors give a precise characterisation of the one-dimensional cellular automata that can be realised by such a sweep. It turns out that not all reversible CA can be realised, while also some non-reversible ones can be obtained. It is decidable whether a CA can be realised that way or not.

Self-Timed Cellular Automata. Self-Timed Cellular Automata (STCA) are a form of Asynchronous Cellular Automata where transitions of cells can take place if they are triggered by transitions of the neighbouring cells. Delay-Insensitive (DI) circuits are asynchronous circuits which make no assumption about delays within modules or wires of circuits, and where there is no global clock [97]. As a result, logical gates such as NAND and XOR are not Turing-complete when operated in a DI environment. A lot of research went into finding universal sets of DI modules and [145] contributes a solution for reversible DI circuits in terms of STCAs. Serial and parallel DI circuits are simulated with new STCAs that contain rules for signal movement, right and left turn, memory toggle, merge, fork and join, and parallel crossing of signals. In addition to a number of reversibility and determinism properties, including local determinism and local reversibility, the STCAs exhibit direction-reversibility, where reversing the direction of a signal and running a circuit forwards is equivalent to running the circuit in reverse. Benefits of direction-reversibility are discussed, including garbage-less implementation of reversible functions.

Cellular Automata as Language Acceptors. From the perspective of language recognition, real-time bounded cellular automata which are reversible on the core of computation, that is, from initial configuration to the configuration given by the time complexity, have been studied in [106]. The question whether for a given real-time CA working on finite configurations with fixed boundary conditions there exists a reverse real-time CA with the same neighbourhood has been addressed. It has been shown that real-time reversibility is undecidable, which contrasts the general case, where reversibility is decidable for one-dimensional devices. Moreover, the undecidability of emptiness, finiteness, infiniteness, inclusion, equivalence, regularity, and context-freedom has been proved. First steps towards the exploration of the computational capacity have been done and closure under Boolean operations have been shown.

Similar investigations for real-time one-way cellular automata have been done in [108]. In this case, it turned out that the standard model with fixed boundary conditions is quite weak in terms of reversible information processing, since it accepts exactly the regular languages reversibly. The extension that allows the information to flow circularly from the leftmost cell into the rightmost cell does not increase the computational power in the general case, but does increase it for reversible computations. On the other hand, the model is less powerful than real-time reversible two-way cellular automata. Additionally, it has been derived that the corresponding language class is closed under Boolean operations, and the undecidability of several decidability questions has been proved. Finally, it turned out that the reversibility of an arbitrary real-time circular one-way cellular automaton is undecidable as well.

8.6 Turing Machines

Turing machines (TM) are a classical model of computation where a finite state control unit, the head, moves along a bi-infinite tape of cells, each containing a tape symbol. The head reads and writes symbols on the tape, changes its internal state, and moves to neighbouring cells at discrete time steps as instructed by a fixed transition rule, the program of the TM. A suitable choice of the program makes the machine reversible (RTM). Turing machines are traditionally viewed as language acceptors, but one can also incorporate outputs in the model so that the machine becomes a transducer that computes a (partial) function. In [12] the authors investigate RTM under the strict function semantics that requires that at the end of the computation only the output remains on the tape, and they develop a rigorous foundational theory of reversible computation of functions in this semantics, including the appropriate concept of universality and a design of a universal machine.

Turing machines with bi-infinite tape contents are also discrete dynamical systems (on a compact space) under two possible viewpoints [104]: in the moving tape view (TMT) the position of the head is fixed but the entire tape shifts left or right depending on the current instruction, while in the usual moving head view (TMH) one needs to allow configurations without a head to make the configuration space compact. In [38] the authors present a reversible TMT with the rather surprising property that it has no halting or temporally periodic configurations, thus answering positively a conjecture made in [92]. The machine, dubbed “SMART”, is small (4 internal states, 3 tape symbols) and nicely symmetric in both time and space. It possesses the good dynamical properties of transitivity and minimality. The machine is further applied to settle another conjecture made in [92]: it is undecidable whether a given complete reversible Turing machine has a periodic orbit.

The class of RTM dynamical systems becomes more robust if the head is allowed to view and modify locally blocks of several tape symbols at once. In particular, compositions of machines and inverse machines are now in the same class so that reversible Turing machines with any fixed states and tape symbols form a group under composition. The structure of this group and algorithmic questions concerning the group are studied in [25]. The paper also introduces a number of natural subgroups. The model includes multidimensional Turing machines where the tape cells are indexed by \(\mathbb {Z}^d\) for dimension d, and both the moving head and the moving tape viewpoints can be taken.

Finally, reversible Turing machines with a working tape and a one-way or two-way read-only input tape are considered as language recognisers [15]. In particular, the classes of languages acceptable by such devices with small time bounds in the range between real time and linear time, that is, with time bounds of the form \(n+r(n)\) where \(r\in o(n)\) is a sublinear function, have been considered. It has been shown that there exist infinite time hierarchies of separated complexity classes in that range. The question of whether reversible Turing machines in the range of interest are weaker than general ones or not is answered positively by proving that there are languages accepted by irreversible one-way Turing machines in real time that cannot be accepted by any reversible one-way machine in less than linear time.

9 Quantum Formal Verification and Quantum Machine Learning

Large-scale, fault-tolerant quantum computers are still under development and, despite a recent major push for “quantum supremacy” by companies like IBM, Google and Intel, it is not clear when they will become a reality. On the other hand there is much recent interest in using Noisy Intermediate Scale Quantum (NISQ) computers to provide a “quantum advantage”. This involves the use of existing or near-term quantum computers to solve valuable problems, faster, cheaper, or more efficiently than any available classical solution. Potential application areas include simulation of many-body physics, quantum chemistry, optimisation and quantum machine learning. Airbus has issued its Quantum Computing Challenge to tackle aerospace flight physics problems using quantum computers. Many companies such as IBM, Microsoft, D-Wave, Rigetti and Xanadu are developing full-stack solutions for implementing quantum algorithms. This typically starts from a high-level programming language and a compiler, down to an assembly language and quantum hardware. These resources are usually accessible via the cloud. Much of these developments will need guarantees regarding security and correctness. Formal verification, which has been used successfully in classical computing for a number of years, could be extremely valuable in increasing confidence in quantum systems.

Quantum cryptography aims to overcome the limitations of classical cryptography by providing unconditional security, which is not dependent on the difficulty of inverting a particular computation. Quantum Key Distribution protocols have been implemented in commercial products by Id Quantique, MagiQ, NEC and Toshiba, amongst others, and have been used in practical applications, e.g. the Geneva election ballot count. Various QKD networks have been built, including the DARPA Quantum Network in Boston, the SeCoQC network around Vienna and the Tokyo QKD Network. China has launched a dedicated satellite “Micius” for quantum communication. On the theoretical side, quantum key distribution protocols such as BB84 [29] have been proved to be unconditionally secure. It is important to understand, however, that this is an information-theoretic proof, which does not necessarily guarantee that implemented systems are unconditionally secure. This area is also where approaches such as those based on formal methods could be useful in analysing behaviour of implemented systems.

The paper [32] presents a novel framework for modelling and verifying quantum protocols and their implementations using the proof assistant Coq. It provides a Coq library for quantum bits (qubits), quantum gates, and quantum measurement. As a step towards verifying practical quantum communication and security protocols such as Quantum Key Distribution, it supports multiple qubits, communication and entanglement. These concepts are illustrated by modelling the Quantum Teleportation Protocol, which communicates the state of an unknown quantum bit using only a classical channel. In more recent work, a Quantum IO monad has been implemented in Coq for the specification of the protocols. In addition to quantum operations and measurement, the monad gives us a lightweight process calculus which supports sequencing of operations and keeping of state. This monad has the necessary properties. The process simulation function that gives the QIO monad its semantics has also been written. Current work concerns proving properties of simple quantum protocols.

In [10], the authors present CCSq, a concurrent language for describing quantum systems, and develop verification techniques for checking equivalence between CCSq processes. CCSq has well-defined operational and superoperator semantics for protocols that are functional, in the sense of computing a deterministic input-output relation for all interleavings arising from concurrency in the system. They have implemented QEC (Quantum Equivalence Checker), a tool that takes the specification and implementation of quantum protocols, described in CCSq, and automatically checks their equivalence. QEC is the first fully automatic equivalence checking tool for concurrent quantum systems. For efficiency purposes, the approach is restricted to Clifford operators in the stabiliser formalism, but it is able to verify protocols over all input states. A collection of interesting and practical quantum protocols, ranging from quantum communication and quantum cryptography to quantum error correction, have been specified and verified.

In other recent work, a version of the quantum process calculus CQP has been implemented. The implementation, which has the working title qtpi and is available from github.com/mdxtoc/qtpi, uses symbolic rather than numeric probability calculation. Programs are checked statically, before they run, to ensure that they obey real-world restrictions on the use of qbits (e.g. no cloning, no sharing). Qtpi has been used to simulate some simple protocols such as teleportation, and some more involved ones including QKD. It is early days in the development of the tool, but it can already simulate well over 1M qbit transfers per minute.

Quantum machine learning is the aspect of quantum computing concerned with the design of algorithms capable of generalised learning from labelled training data by effectively exploiting quantum effects. The undertaken work makes various contributions to this emerging area; in particular it has pursued the issue of classification error within a standard quantum computational setting, and explored the congruence of Kernel Methods with the topological quantum computational setting (a congruence that will be developed further in future work).

Specifically, the following have been achieved:

In [52] the authors present a novel approach to computing Hamming distance and its kernelisation within Topological Quantum Computation. This approach is based on an encoding of two binary strings into a topological Hilbert space, whose inner product yields a natural Hamming distance kernel on the two strings. Kernelisation forges a link with the field of Machine Learning, particularly in relation to binary classifiers such as the Support Vector Machine (SVM). This makes our approach of potentially wide interest to the quantum machine learning community.

In [183], the authors set out a strategy for quantising attribute bootstrap aggregation to enable variance-resilient quantum machine learning. To do so, they utilise the linear decomposability of decision boundary parameters in the Rebentrost et al. Support Vector Machine [164] to guarantee that stochastic measurement of the output quantum state will give rise to an ensemble decision without destroying the superposition over projective feature subsets induced within the chosen SVM implementation. It achieves a linear performance advantage, O(d), in addition to the existing \(O(\log (n))\) advantages of quantisation as applied to Support Vector Machines. The approach extends to any form of quantum learning giving rise to linear decision boundaries.

Error-correcting output codes (ECOC) are a standard setting in machine learning for efficiently rendering the collective outputs of a binary classifier, such as the support vector machine, as a multi-class decision procedure. Appropriate choice of error-correcting codes further enables incorrect individual classification decisions to be effectively corrected in the composite output. In [182], the authors propose an appropriate quantisation of the ECOC process, based on the quantum support vector machine. They show that, in addition to the usual benefits of quantising machine learning, this technique leads to an exponential reduction in the number of logic gates required for effective correction of classification error.

10 Conclusion

We gave in the previous sections an overview of the status and recent developments of different research threads on the foundations of reversible computation. While many interesting results have been found, we notice that the field is still very heterogeneous. For instance, while process calculi, Petri nets and cellular automata are all models of concurrent systems, they come equipped with different notions of reversibility. Cellular automata are considered reversible if the global dynamics is bijective (similarly to what is done in sequential reversible models), Petri nets if reverse transitions can be added without changing the behaviour of the net, while process calculi are mainly based on the notion of causal-consistent reversibility. Some initial cross-fertilisation results came thanks to the COST Action, e.g. there have been works applying causal-consistent reversibility to Petri nets [132] and related models [27, 155]. We also remark that some of the developments described in this chapter have been instrumental to better understand reversibility in programming languages and to advance on a number of application areas, as discussed in the rest of the book.