Skip to main content
Springer Nature - PMC COVID-19 Collection logoLink to Springer Nature - PMC COVID-19 Collection
. 2020 Jun 17;12227:111–127. doi: 10.1007/978-3-030-52482-1_6

Reversible Programming Languages Capturing Complexity Classes

Lars Kristiansen 10,11,✉
Editors: Ivan Lanese8, Mariusz Rawski9
PMCID: PMC7345302

Abstract

We argue that there is a link between implicit computational complexity theory and the theory of reversible computation. We show that the complexity classes Inline graphic and Inline graphic can be captured by inherently reversible programming languages.

Introduction

The title above is inspired by the title of a paper I co-authored with Paul Voda more than 15 years ago: Programming languages capturing complexity classes [10]. In that paper we related the computational power of fragments of programming languages to complexity classes defined by imposing time and space constraints on Turing machines. Around that time, I authored and co-authored a number of related papers, e.g. [8, 9, 11], all of which were clearly inspired by work in implicit computational complexity theory from the 1990s, e.g., Bellatoni and Cook [2], Leivant [12, 13] and, particularly, Jones [5, 6].

Complexity classes like Inline graphic, Inline graphic, Inline graphic, Inline graphic, Inline graphic, and so on, are defined by imposing explicit resource bounds on a particular machine model, namely the Turing machine. E.g., Inline graphic is defined as the class of functions computable in polynomial time on a deterministic Turing machine. The definition puts constraints on the resources available to the Turing machines, but no constraints on the algorithms available to them. A Turing machine may compute a function in the class by any imaginable algorithm as long as it works in polynomial time. Implicit computational complexity theory studies classes of functions (problems, languages) that are defined without imposing explicit resource bounds on machine models, but rather by imposing linguistic constraints on the way algorithms can be formulated. When we explicitly restrict our language for formulating algorithms, that is, our programming language, then we may implicitly restrict the computational resources needed to execute algorithms. If we manage to find a restricted programming language that captures a complexity class, then we will have a so-called implicit characterization. A seminal example is Bellatoni and Cook’s [2] characterization of Inline graphic. They give a functional programming language (which they call a function algebra). This language consists of a few initial functions and two definition schemes (safe composition and safe primitive recursion) which allow us to define new functions. These schemes put rather severe syntactical restrictions on how we can define functions, but they do not refer to polynomially bounded Turing machines or any other kind of resource bounded computing machinery. It is not easy to write programs when we have to stick to these schemes, even experienced programmers might find it hard to multiply two numbers but, be that as it may, this is a programming language that yields an implicit characterization of a complexity class. It turns out that a function can be computed by a program written in Bellantoni & Cook’s language if and only if it belongs to the complexity class Inline graphic.

There is an obvious link between implicit computational complexity and reversible computing. A programming language based on natural reversible operations will impose restrictions on the way algorithms can be formulated, and thus, also restrictions on the computational resources needed to execute algorithms. Hence, the following question knocks at the door: Will it be possible find reversible programming languages that capture some of the standard complexity classes? The answer turns out to be YES. We will present a reversible language that captures, or if you like, gives an implicit characterization of, the (maybe not very well-known) complexity class Inline graphic. A few small modifications of this language yield a reversible language that captures the very well-known complexity class Inline graphic.

Our languages are based on a couple of naturally reversible operations. To increase, or decrease, a natural number by 1 modulo a base b is such an operation: Inline graphic. The successor of Inline graphic becomes 0, and then Inline graphic becomes the predecessor of 0. Thus, “increase” and “decrease” are the reverse of each other. To move an element from the top of one stack to the top of another stack is another such operation as we can simply move the element back to the stack it came from.

This paper addresses students and researchers interested in programming languages, reversible computations and computer science in general, they will not necessarily be experts in computability or complexity theory. We will give priority to readability over technical accuracy, but still this is a fairly technical paper, and we will assume that the reader is faintly acquainted with Turing machines and basic complexity theory (standard textbooks are Arora and Barac [1], Jones [7] and Sipser [16]).

Implicit computational complexity theory is definitely a broader and richer research area than our short discussion above may indicate. More on the subject can be found in Dal Lago [3].

Reversible Bottomless Stack (RBS) Programs

An infinite sequence of natural numbers Inline graphic is a bottomless stack if there exists k such that Inline graphic for all Inline graphic. We use Inline graphic to denote the bottomless stack Inline graphic where Inline graphic when Inline graphic, and Inline graphic when Inline graphic. We say that Inline graphic is the top element of Inline graphic. Observe that 0 is the top element of the stack Inline graphic. Furthermore, observe that Inline graphic is the same stack as Inline graphic (since Inline graphic and Inline graphic denote the same sequence of natural numbers). We will refer to Inline graphic as the zero stack.

The syntax of the imperative programming language RBS is given in Fig. 1. Any element in the syntactic category Command will be called a program, and we will use the word command and the word program interchangeably throughout the paper. We will now explain the semantics of RBS.

Fig. 1.

Fig. 1.

The syntax of the language RBS. The variable X in the loop command is not allowed to occur in the loop’s body.

An RBS program manipulates bottomless stacks, and each program variable holds such a stack. The input to a program is a single natural number m. When the execution of the program starts, the input m will be stored at the top of the stack hold by Inline graphic, that is, we have Inline graphic. All other variables occurring in the program hold the zero stack when the execution starts. A program is executed in a base b which is determined by the input: we have Inline graphic if Inline graphic when the execution starts. The execution base b is kept fixed during the entire execution.

Let Inline graphic and Inline graphic be program variables. We will now explain how the primitive commands work. The command Inline graphic pops off the top element of the stack held by Inline graphic and pushes it onto the stack held by Inline graphic, that is

graphic file with name 501864_1_En_6_Equ40_HTML.gif

The command Inline graphic increases the the top element of the stack held by Inline graphic by Inline graphic, that is

graphic file with name M45.gif

The command Inline graphic decreases the the top element of the stack held by Inline graphic by Inline graphic, that is

graphic file with name M49.gif

Observe that we have

graphic file with name M50.gif

and

graphic file with name M51.gif

when b is the base of the execution.

The semantics of the command Inline graphic is as expected. This is the standard composition of the commands Inline graphic and Inline graphic, that is, first Inline graphic is executed, then Inline graphic is executed. The command Inline graphic executes the command Inline graphic repeatedly k times in a row where k is the top element of the stack held by Inline graphic. Note that the variable Inline graphic is not allowed to occur in Inline graphic and, moreover, the command Inline graphic will not modify the stack held by Inline graphic.

Example 1

Let Inline graphic be the program Inline graphic. We have

graphic file with name M65.gif

Let Inline graphic be the program Inline graphic. We have

graphic file with name M68.gif

since the execution base is 18. All numbers stored on stacks during an execution will be strictly less than the execution base, and thus, less than or equal to Inline graphic where m is the input.    Inline graphic

Intuitively, it should be clear that Inline graphic programs are reversible in a very strong sense. Inline graphic is an inherently reversible programming language in the terminology of Matos [14]. If we like, we can of course state this insight more formally. The next definition and the following theorem will be a step in that direction.

Definition 2

We define reverse command of C, written Inline graphic, inductively over the structure C:

  • Inline graphic

  • Inline graphic

  • Inline graphic

  • Inline graphic

  • Inline graphic.

   Inline graphic

Theorem 3

Let Inline graphic be a program, and let Inline graphic be the variables occurring in Inline graphic. Furthermore, let m be any natural number. We have

graphic file with name M83.gif

It is a nice, and maybe even challenging, exercise to write up a decent proof Theorem 3, even if it should be pretty clear that the theorems holds. We will offer a proof in the next section. The reader not interested in the details of the proof, may skip that section.

We will now define the set of problems that can be decided by an Inline graphic programs. To that end, we need to determine how an Inline graphic program should accept, and how an Inline graphic program should reject, its input. Any reasonable convention will do, and we will just pick a simple and convenient one.

Definition 4

An RBS program C accepts the natural number m if C executed with input m terminates with 0 at the top of the stack hold by Inline graphic, otherwise, C rejects m.

A problem is a set of natural numbers.1 An RBS program C decides the problem A if C accepts all m that belong to A and rejects all m that do not belong to A. Let Inline graphic denote class of problems decidable by an RBS program.    Inline graphic

Let A be the set of even numbers. Then A is a problem. Figure 2 shows an RBS program that decides A.

Fig. 2.

Fig. 2.

The program accepts every even number and rejects every odd number.

Now, any RBS program decides a problem, and Inline graphic is obviously a well-defined class of computable (decidable) problems. We have defined Inline graphic by a reversible programming language. We have not defined Inline graphic by imposing resource bounds on Turing machines or any other machine models. What can we say about the computational complexity of the problems we find in Inline graphic? May it be the case that Inline graphic equals a complexity class?

The Proof of Theorem 3

This section is dedicated to a detailed proof of Theorem 3 (readers not interested may jump ahead to Sect. 4). First, we need some terminology and notation: We will say that a (bottomless) stack is a b-stack if every number stored on the stack is strictly smaller than b. Furthermore, we will use Inline graphic to denote the set of program variables occurring in the command Inline graphic, and for any positive integer m and any command Inline graphic, we define the command Inline graphic by Inline graphic and Inline graphic.

Now, assume that Inline graphic is an Inline graphic command with Inline graphic. Furthermore, assume that Inline graphic is executed in base b and that Inline graphic are b-stacks. With these assumptions in mind, we make the following claim:

graphic file with name M106.gif claim

Theorem 3 follows straightforwardly from this claim. So all we need to do is to prove the claim.

We will of course carry out induction on the structure of the command Inline graphic, and our proof will split into the tree base cases (i) Inline graphic, (ii) Inline graphic and (iii) Inline graphic and the two inductive cases (iv) Inline graphic and Inline graphic (see Fig. 1).

Case (i). Assume

graphic file with name M113.gif

Then we also have Inline graphic where

graphic file with name M115.gif

for some Inline graphic. We have Inline graphic when Inline graphic. Thus we have Inline graphic. By Definition 2, we have Inline graphic. Now, since neither Inline graphic nor Inline graphic will modify any stack held by a variable Inline graphic where Inline graphic, we also have

graphic file with name M125.gif

This concludes the proof of case (i). The proofs of the cases (ii) and (iii) are very similar to the proof of case (i). We leave the details to the reader and proceed with the inductive cases.

Case (iv). Assume

graphic file with name M126.gif

Then there exist b-stacks Inline graphic such that

graphic file with name M128.gif

We apply our induction hypothesis both to Inline graphic and to Inline graphic and conclude

graphic file with name M131.gif

It follows that

graphic file with name M132.gif

Finally, as Definition 2 states that Inline graphic, we have

graphic file with name M134.gif

This completes the proof of case (iv).

Case (v). Assume

graphic file with name M135.gif *

and let m be the top element of the stack Inline graphic.

If Inline graphic, we have

graphic file with name M138.gif

as the command Inline graphic will not be executed at all. Thus, we also have

graphic file with name M140.gif

and by Definition 2, we have

graphic file with name M141.gif

This proves that the claim holds when Inline graphic. We are left to prove that the claim holds when Inline graphic. Thus, in the remainder of this proof we assume that Inline graphic.

First we prove

graphic file with name M145.gif †

by a secondary induction on m.

Let Inline graphic. Then we have Inline graphic, and an application of our main induction hypothesis to Inline graphic yields (Inline graphic). Let Inline graphic. Then we have

graphic file with name M151.gif

and (Inline graphic) holds by our induction hypothesis on m and case (iv) above. This concludes the proof of (Inline graphic).

We are now ready to complete our proof the claim. By (*), we have

graphic file with name M154.gif

By (Inline graphic), we have

graphic file with name M156.gif

Since Inline graphic, we have Inline graphic, and thus, the top element of Inline graphic is the same as the top element of Inline graphic, namely m. It follows that

graphic file with name M161.gif

Finally, as Definition 2 states that Inline graphic, we have

graphic file with name M163.gif

This completes the proof of case (v).

Simulation of Turing Machines

A General Strategy

Let us first see how we can simulate a Turing machine in a standard way in a standard high-level language. Thereafter we will discuss how we can simulate a Turing machine in our rudimentary reversible language. In the standard language we will of course be able to simulate any Turing machine, no matter how much time and space resources the machine requires. In the reversible language we will only be able to simulate those Turing machines that run in time Inline graphic (where k is a constant and n is the length of the input).

We assume some familiarity with Turing machines. The reader is expected to know that a Turing machine computes by writing symbols from a finite alphabet Inline graphic on an infinite tape which is divided into cells; know that one of the cells is scanned by the machine’s head; know a there is a finite number of states Inline graphic; and so on.

The input w will be available on the tape when a Turing machine M starts, and the actions taken by M will be governed by a finite transition table. Each entry of the table is a 5-tuple

graphic file with name M167.gif *

where Inline graphic are alphabet symbols; Inline graphic are states; and D is ether “left” or “right”. Such a tuple is called a transition and tells M what to do when it scans the symbol Inline graphic in state Inline graphic: in that case M should write the symbol Inline graphic, move its head one position in the direction given by D, and then proceed in state Inline graphic. We restrict our attention to deterministic Turing machines, and for each alphabet symbol Inline graphic and each non-halting state Inline graphic, there will be one, and only one, transition that starts with Inline graphic. So a Turing machine knows exactly what to do until it reaches one its halting states, and then it simply halts (if it halts in a dedicated state Inline graphic, it accepts its input; if it halts in a dedicated state Inline graphic, it rejects its input). This entails that we can simulate a Turing machine by a sequence of if-then statements embedded into a while-loop. We need one if-then statement for each transition:

graphic file with name 501864_1_En_6_Equ41_HTML.gif

Minimum one transition will be executed each time the loop’s body is executed, and the running time of M (on input w) will more or less be the number of times the body is executed. (It might happen that more than one transition is executed when the loop’s body is executed once, but that will not cause any trouble.) In order to simulate the actions taken by the transitions, we need a representation of the computing machinery. We need to keep track of the current state, we need to keep track of the symbols on the tape, and we need to identify the scanned cell. The current state can simply be stored in a register Inline graphic, but how should we deal with the tape? The tape is divided into an infinite sequence of cells

graphic file with name M180.gif

where one of the cells Inline graphic is scanned by the head. Only finitely many of these cells will contain anything else than the blank symbol. Let us say that Inline graphic contains blank when Inline graphic. In order to simulate the machine it will obviously be sufficient to store the symbols in the cells Inline graphic where Inline graphic. In addition we need to keep track of the scanned cell Inline graphic. A convenient way to deal with the situation will be to use a stack Inline graphic, a register SCAN, another stack Inline graphic, and store the tape content in the following way:

graphic file with name 501864_1_En_6_Equ42_HTML.gif

Now we can mimic the movements of the head by pushing and popping alphabet symbols in the obvious way, and the transition (*) can be implemented by a program of the form

graphic file with name 501864_1_En_6_Equ43_HTML.gif

Can RBS Programs Simulate Turing Machines?

The input to an RBS program is a natural number, and we will thus discuss to what extent an RBS program can simulate a Turing machine that takes a single natural number as input.

We have seen that a program with only one while-loop can simulate a Turing machine (and we will for sure need at least one while-loop in order to simulate an arbitrary Turing machine). Now, while-loops are not available in RBS, and the best we can do in order to simulate a Turing machine is to use a fixed number of nested for-loops:

graphic file with name M189.gif

Since an RBS program cannot increase the numerical value of its input, the body of each of these loops will be executed maximum Inline graphic times where m is the input to the RBS program (and to the Turing machine the program simulates). Thus it is pretty clear that we cannot simulate a Turing machine if its running time is not bounded by Inline graphic for some constant k. This corresponds to a bound Inline graphic where k is a constant and |m| is the length of the input m, that is, |m| equals the number of symbols needed to represent the natural number m in binary notation. In the following we will see that any Turing machine that uses such an amount of computation time can be simulated by an RBS program.

It turns out that an RBS program can simulate the transitions of a Turing machine M in essentially the same way as the high-level program sketched above, given that the input to M is sufficiently large (on small inputs the simulation might fail). Stacks are directly available in RBS, and thus an RBS program can easily represent the tape and mimic the movements of the head. On the other hand, assignment statements and if-then statements are not directly available. This makes things a bit tricky. Let us first see how RBS programs to a certain extent can simulate programs written in a non-reversible programming language called Inline graphic.

Inline graphic Programs

The syntax of Inline graphic is given in Fig. 3. Any element in the syntactic category Command will be called a program. A Inline graphic program manipulates natural numbers, and each program variable holds a single natural number. The command Inline graphic assigns the fixed number k to the variable Inline graphic. The command Inline graphic assigns the number hold by the variable Inline graphic to the variable Inline graphic. The command Inline graphic decreases the value hold by the variable Inline graphic by 1 if the value is strictly greater than 0; and leave the value hold by Inline graphic unchanged if the value is 0. Furthermore, the command Inline graphic is the standard composition of the commands Inline graphic and Inline graphic, and the command Inline graphic executes the command Inline graphic repeatedly k times in a row where k in the number hold by Inline graphic. Note that the variable Inline graphic is not allowed to occur in Inline graphic and that the command Inline graphic does not modify the value held by Inline graphic.

Fig. 3.

Fig. 3.

The syntax of the language Inline graphic. The variable X in the loop command is not allowed to occur in the loop’s body.

An RBS program can represent a Inline graphic variable Inline graphic holding natural number k by a variable Inline graphic (we use the same variable name) holding the stack Inline graphic. The command Inline graphic can then be simulated by the program

graphic file with name M221.gif

where Inline graphic is an auxiliary variable (Inline graphic works as a trash bin). Now, observe that this will only work if the base of execution is strictly greater than k, but that will good enough to us. The command Inline graphic can be simulated by the program

graphic file with name M225.gif

where Inline graphic is an auxiliary variable (Inline graphic works as a trash bin). Furthermore, the command Inline graphic can be simulated by a program that uses auxiliary variables Inline graphic and Inline graphic (which represent natural numbers) and the simulations of the assignment statements given above:

graphic file with name 501864_1_En_6_Equ44_HTML.gif

This shows how Inline graphic programs can simulate all the primitive Inline graphic commands. It is easy to see that

  • the RBS command Inline graphic simulates the Inline graphic command Inline graphic if Inline graphic simulates Inline graphic and Inline graphic simulates Inline graphic

  • the RBS command Inline graphic simulates the Inline graphic command Inline graphic if Inline graphic simulates Inline graphic.

Hence, any Inline graphic program can be simulated by an Inline graphic program given that the input is sufficiently large. On small inputs simulations might fail since the simulation of the assignment Inline graphic only works if the execution base is strictly greater than k.

The Inline graphic language turns out to be more expressive than one might expect at a first glance, and all sorts of conditional statements and if-then constructions are available in the language. As an example, let us see how we can implement the construction

graphic file with name M249.gif

We will need some axillary variables Inline graphic, Inline graphic, Inline graphic, Inline graphic which do not occur in any of the commands Inline graphic and Inline graphic. First we execute the program

graphic file with name 501864_1_En_6_Equ45_HTML.gif

This program sets both Inline graphic and Inline graphic to 0 if Inline graphic and Inline graphic hold the same number. If Inline graphic and Inline graphic hold different numbers, one of the two variables Inline graphic will be set to a number strictly greater than 0. Then we execute the program

graphic file with name 501864_1_En_6_Equ46_HTML.gif

The composition of these two programs executes the program Inline graphic exactly once (and Inline graphic will not be executed at all) if Inline graphic and Inline graphic hold the same number. If Inline graphic and Inline graphic hold different numbers, Inline graphic will be executed exactly once (and Inline graphic will not be executed at all). The reader should note that this implementation of if-then-else construction does not contain any assignments of the form Inline graphic where Inline graphic.

It is proved in Kristiansen [8] that Inline graphic captures the complexity class Inline graphic, that is, the set of problems decidable in space O(n) on a deterministic Turing machine (n is the length of the input). Hence, the considerations above indicate that Inline graphic. However, we are on our way to proving a stronger result, namely that Inline graphic. The equality Inline graphic is one of the many notorious open problems of complexity theory. The general opinion is that the equality does not hold.

RBS Programs that Simulates Time-Bounded Turing Machines

We have seen that RBS programs (nearly) can simulate Inline graphic programs. Inline graphic can assign constants to registers and perform if-then-else constructions. This helps us to see how to an RBS program can simulate an arbitrary Inline graphic time Turing machine M. Such a program may be of the form

graphic file with name M281.gif

We represent the symbols in M’s alphabet Inline graphic by the numbers Inline graphic and M’s states Inline graphic by the numbers Inline graphic. We use two stacks to hold the content of the tape, and we use registers Inline graphic and SCAN to hold respectively the current state and the scanned cell. Each Inline graphic will take care of a transition Inline graphic and be of the form

graphic file with name M289.gif

We are left with a minor problem: This will not work for small inputs. This will only work if the base of execution Inline graphic is strictly greater than Inline graphic. Only then will the simulating program be able to perform the necessary assignments of constants to variables. In some sense we cannot deal with this problem. An RBS program will not be able to simulate (in any reasonable sense of the word) an arbitrary Inline graphic time Turing machine M on small inputs, but still there will be an RBS program that decides the same problem as M.

We have seen that it suffices to assign the constants 0 and 1 to variables in order to implement the if-then-else construction in Inline graphic. This entails that the if-then-else construction will work on small inputs as the base of execution always will be strictly greater than 1. Hence, if the problem A is decided by a Inline graphic time Turing machine M, there will also be an RBS program that decides A. This program will be of the form

graphic file with name 501864_1_En_6_Equ47_HTML.gif

Main Results

A Characterization of Inline graphic

Definition 5

Let |m| denote the number of digits required to write the natural number m in binary notation. For any natural number k, let Inline graphic be the class of problems decidable in time Inline graphic on a deterministic Turing machine. Let Inline graphic.    Inline graphic

Theorem 6

Inline graphic.

Proof

The proof of the inclusion Inline graphic should be straightforward to anyone experienced with Turing machines. Assume Inline graphic (we will argue that Inline graphic). Then there is an Inline graphic program Inline graphic that decides A. Let m be the input to Inline graphic. Each loop in Inline graphic will be executed maximum Inline graphic times since the base of execution will be Inline graphic. Thus, there exist constants Inline graphic (not depending on m) such that Inline graphic bounds the number of primitive commands executed by Inline graphic on input m. A Turing machine can simulate the execution of Inline graphic on input m with polynomial overhead. Thus there exist constants Inline graphic such that Inline graphic bounds the number of steps a Turing machine needs to decide if m is in A. There exists k such that Inline graphic. Hence, Inline graphic. This proves the inclusion Inline graphic.

We turn to proof of the inclusion Inline graphic. Assume Inline graphic (we will argue that Inline graphic). Then there is a Inline graphic time Turing machine M that decides A. Now, M will run in time Inline graphic when Inline graphic is sufficiently large. In the previous section we saw that there will be an RBS program that decides the same problem as M. Hence, Inline graphic. This proves the inclusion Inline graphic.   Inline graphic

A Characterization of Inline graphic

Would it not be nice if we could find a reversible language that captures a complexity class that is a bit more attractive than Inline graphic? Now, Inline graphic is for a number of reasons, which the reader might be aware of, one of most popular and important complexity classes. Luckily, it turns out that a few modifications of RBS yield a characterization of Inline graphic.

First we modify the way Inline graphic programs receive input. The input will now be a string over some alphabet. Any alphabet that contains at least two symbols will do and, for convenience, we will stick to the alphabet Inline graphic. The base of execution will at program start be set to the length of the input. Otherwise, nearly everything is kept as before: Every variable will still hold a bottomless stack storing natural numbers. All commands available in the original version of RBS will be available in the new version. A program will still accept its input by terminating with 0 at the top of the stack held by Inline graphic, otherwise, the program rejects its input. Moreover, all variables including Inline graphic, the variable that used to import the input, hold the zero stack when the execution of a program starts.

Next we extend Inline graphic by two commands with the syntax

graphic file with name M337.gif

where X is a variable and com is a command which does not contain X. These commands make it possible for a program to access its input. The input is a string Inline graphic where b is the execution base and Inline graphic. Assume that Inline graphic holds a stack where top element is k. The command

graphic file with name M341.gif

executes the command Inline graphic if Inline graphic, otherwise, the command does nothing. The command

graphic file with name M344.gif

executes the command Inline graphic if Inline graphic, otherwise, the command does nothing.

We still have a reversible language. The two new commands are reversible. The variable Inline graphic is not allowed to occur in Inline graphic and will consequently not be modified by Inline graphic. Thus, for Inline graphic, we may extend Definition 2 by

graphic file with name M351.gif

and Theorem 3 will still hold.

To avoid confusion we will use Inline graphic to denote our new version of RBS. We require that the input to an Inline graphic program is of length at least 2 (so we exclude the empty string and the one-symbol strings a and b). This is of course a bit artificial, but it seems to be the most convenient way to deal with a few annoying problems of technical nature. Accordingly, we also require that every string in a language (see the definition below) is of length at least 2.

Definition 7

A language L is a set of strings over the alphabet Inline graphic , moreover, every string in L is of length at least 2.

An Inline graphic program C decides the language L if C accepts every string that belongs to L and rejects every string that does not belong to L. Let Inline graphic be class of languages decidable by an RBS’ program.

Let |w| denote the length of the string w. For any natural number k, let Inline graphic be the class of languages decidable in time Inline graphic on a deterministic Turing machine. Let Inline graphic.   Inline graphic

Figure 4 shows an Inline graphic program which decides the language given by the regular expression Inline graphic.

Fig. 4.

Fig. 4.

The program accepts any string that starts with a nonempty sequence of a’s and ends with a single b (the input to a program should at least contain two symbols). The program rejects any string that is not of this form. The program accepts by terminating with Inline graphic and rejects by terminating with Inline graphic.

The proof of the next theorem is very similar to the proof of Theorem 6, and the reader should be able to provide the details. Just recall that the execution base of an Inline graphic program is set to the length of the input. Hence, the number of primitive instructions executed by an Inline graphic program will be bounded by Inline graphic where |w| is the length of the input w and k is a sufficiently large constant, and moreover, an Inline graphic program of the form

graphic file with name M369.gif

will execute Inline graphic exactly Inline graphic times if each and one of the variables Inline graphic holds a stack where the top element is |w|.

Theorem 8

Inline graphic.

Some Final Remarks

We have argued that there is a link between implicit computational complexity theory and the theory of reversible computation, and we have showed that both Inline graphic and Inline graphic can be captured by inherently reversible programming languages. In general, implicit characterizations are meant to shed light on the nature of complexity classes and the many notoriously hard open problems involving such classes. Implicit characterizations by reversible formalisms might yield some new insights in this respect. It is beyond the scope of this paper to discuss or interpret the theorems proved above any further, but one might start to wonder how different aspects of reversibility relate to time complexity, space complexity and nondeterminism.

The author is not aware of any work in reversible computing that is closely related to the work presented above, but some work of Matos [14] is at least faintly related. Matos characterizes the primitive recursive functions by an inherently reversible loop-language.2 Paolini et al. [15] do also characterize the primitive recursive functions by a reversible formalism. Their work is of a recursion-theoretic nature and has a different flavor than ours, but it is possible that such studies might lead to interesting characterizations of complexity classes.

We finish off this paper by suggesting a small research project. It should be possible to extend Inline graphic to an inherently reversible higher-order language. First-order programs will be like the ones defined and explained above. Second-order programs will manipulate stacks of stacks, third-order programs will manipulate stacks of stacks of stacks, and so on. This will induce a hierarchy: the class of problems decidable by a first-order Inline graphic program, the class of problems decidable by a second-order Inline graphic program, ...by a third-order Inline graphic program, and so on. By the same token, Inline graphic will induce a hierarchy: the class of languages decidable by a first-order Inline graphic program, the class of languages decidable by a second-order Inline graphic program, and so on. These two hierarchies should be compared to the alternating time-space hierarchies studied in Goerdt [4], Jones [6], Kristiansen and Voda [10] and many other papers.

Footnotes

1

It is pretty standard in computability and complexity theory to define a problem as a set of natural numbers.

2

The result is not stated very clearly in the paper. See the footnote at page 2066.

Contributor Information

Ivan Lanese, Email: ivan.lanese@gmail.com.

Mariusz Rawski, Email: mariusz.rawski@gmail.com.

Lars Kristiansen, Email: larsk@math.uio.no.

References

  • 1.Arora S, Barak B. Computational Complexity: A Modern Approach. Cambridge: Cambridge University Press; 2009. [Google Scholar]
  • 2.Bellantoni SJ, Cook S. A new recursion-theoretic characterizations of the polytime functions. Comput. Complex. 1992;2:97–110. doi: 10.1007/BF01201998. [DOI] [Google Scholar]
  • 3.Dal Lago U. A short introduction to implicit computational complexity. In: Bezhanishvili N, Goranko V, editors. Lectures on Logic and Computation; Heidelberg: Springer; 2012. pp. 89–109. [Google Scholar]
  • 4.Goerdt A. Characterizing complexity classes by higher type primitive recursive definitions. Theoret. Comput. Sci. 1992;100:45–66. doi: 10.1016/0304-3975(92)90363-K. [DOI] [Google Scholar]
  • 5.Jones ND. LOGSPACE and PTIME characterized by programming languages. Theoret. Comput. Sci. 1999;228:151–174. doi: 10.1016/S0304-3975(98)00357-0. [DOI] [Google Scholar]
  • 6.Jones ND. The expressive power of higher-order types or, life without CONS. J. Funct. Program. 2001;11:55–94. doi: 10.1017/S0956796800003889. [DOI] [Google Scholar]
  • 7.Jones ND. Computability and Complexity from a Programming Perspective. Cambridge: The MIT Press; 1997. [Google Scholar]
  • 8.Kristiansen L. Neat function algebraic characterizations of LOGSPACE and LINSPACE. Comput. Complex. 2005;14:72–88. doi: 10.1007/s00037-005-0191-0. [DOI] [Google Scholar]
  • 9.Kristiansen L, Niggl K-H. On the computational complexity of imperative programming languages. Theoret. Comput. Sci. 2004;318:139–161. doi: 10.1016/j.tcs.2003.10.016. [DOI] [Google Scholar]
  • 10.Kristiansen L, Voda PJ. Programming languages capturing complexity classes. Nord. J. Comput. 2005;12:89–115. [Google Scholar]
  • 11.Kristiansen L, Voda PJ. Complexity classes and fragments of C. Inf. Process. Lett. 2003;88:213–218. doi: 10.1016/j.ipl.2003.08.010. [DOI] [Google Scholar]
  • 12.Leivant, D.: A foundational delineation of computational feasibility. In: Proceedings Sixth Annual IEEE Symposium on Logic in Computer Science, pp. 39–47. IEEE (1991)
  • 13.Leivant, D.: Stratified functional programs and computational complexity. In: POPL 1993: Proceedings of the 20th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 325–333. ACM, New York (1993)
  • 14.Matos AB. Linear programs in a simple reversible language. Theoret. Comput. Sci. 2003;290:2063–2074. doi: 10.1016/S0304-3975(02)00486-3. [DOI] [Google Scholar]
  • 15.Paolini L, Piccolo M, Roversi L. On a class of reversible primitive recursive functions and its Turing-complete extensions. New Gener. Comput. 2018;36:233–256. doi: 10.1007/s00354-018-0039-1. [DOI] [Google Scholar]
  • 16.Sipser M. Introduction to the Theory of Computation. Boston: PWS Publishing Company; 1997. [Google Scholar]

Articles from Reversible Computation are provided here courtesy of Nature Publishing Group

RESOURCES