A Linear-Time Self-Interpreter of a Reversible Imperative Language

A Linear-Time Self-Interpreter of a Reversible Imperative Language

Information and Media Technologies 11: 160-180 (2016) reprinted from: Computer Software 33(3): 108-128 (2016) © Japan Society for Software Science and Technology 推薦論文● PPL 2015 A Linear-Time Self-Interpreter of a Reversible Imperative Language Robert Gl¨uck Tetsuo Yokoyama A linear-time reversible self-interpreter in an r-Turing complete reversible imperative language is presented. The proposed imperative language has reversible structured control flow operators and symbolic tree- structured data (S-expressions). The latter data structures are dynamically allocated and enable reversible simulation of programs of arbitrary size and space consumption. As self-interpreters are used to show a number of fundamental properties in classic computability and complexity theory, the present study of an efficient reversible self-interpreter is intended as a basis for future work on reversible computability and com- plexity theory as well as programming language theory for reversible computing. Although the proposed reversible interpreter consumes superlinear space, the restriction of the number of variables in the source language leads to linear-time reversible simulation. Examples of recently shown properties include the 1 Introduction structured program theorem [32] and the universal- Reversible computing is a relatively young area of ity of Turing machines [2]. computer science that studies the theory and prac- This paper deals with the question of the exis- tice of forward and backward computation on all tence of linear-time self-interpretation in reversible levels of the computation stack ranging from logic computing (i.e., efficient interpretation in the sense circuits and computer architectures to program- of Jones [16]). Linear-time interpreters are used ming languages and algorithms (e.g. [8][29][34]). in computability and complexity theory. Among Reversible programming languages compute only others, they are used to show the existence of a injective functions [2] owing to the forward and linear-time complexity hierarchy along the lines backward determinism of the underlying compu- of Jones [16][17] and of Levin’s optimal univer- tation model. This means that there is a unique sal search [18][13]. Although linear-time self- relation between the input and the output of a re- interpretation is a good property to have in any versible program. The validity of several funda- computation model, no such self-interpreter is mental programming language theories, whose ir- known in some models (cf. a universal Turing ma- reversible counterparts are often taken for granted, chine as fast as that with a logarithmic-time over- has not yet been examined in reversible computing. head is known [19]), whereas it is for the pure un- typed lambda calculus [21] and for Jones’ imper- ative I language [16]. However, the existence of 可逆命令型言語の線形時間自己解釈系 linear-time self-interpreters in irreversible comput- ロバート・グリュック, コペンハーゲン大学計算機科学 ing does not imply the corresponding result for re- 部, DIKU, Department of Computer Science, Uni- versity of Copenhagen. versible computing. 横山哲郎, 南山大学理工学部ソフトウェア工学科, Depart- We begin by introducing the language R-WHILE, ment of Software Engineering, Nanzan University. a reversible version of Jones’ WHILE language. The コンピュータソフトウェア,Vol.33, No.3 (2016),pp.108–128. language has structured control flow operators [研究論文] 2015 年 7 月 30 日受付. and symbolic tree-structured data (S-expressions 160 Information and Media Technologies 11: 160-180 (2016) reprinted from: Computer Software 33(3): 108-128 (2016) © Japan Society for Software Science and Technology known from Lisp). The latter allows for the mod- and their input and output are written in type- eling of many familiar data structures in a simple writer font. If p is a program written in the lan- way, which is more difficult in existing reversible guage S,then[[p]] S denotes the meaning of p, i.e., imperative languages such as Janus, which only the input–output function that p computes. Thus, provide integers, arrays, and stacks. It was only the output d =[[p]] S(d) results from running p on recently shown how to represent and manipulate bi- the input d. It is undefined if the program does not nary trees in the heap of a reversible random-access terminate. machine [3]. We shall see that a linear-time self- We assume that programs compute with trees interpreter exists in R-WHILE-M,anr-Turingcom- built from a finite set of atoms. The data domain D plete subset of the language R-WHILE in which the of a program is the smallest set that contains the fi- number of variables is bounded. nite set of atoms and all of the pairs (d1.d2),where The reversible structured control flow operators d1, d2 ∈ D. of the reversible imperative reversible language R-WHILE-M are instances of those of the reversible 2. 1 Standard Interpreter flowchart language [34]. There are other r-Turing An L-program int is an interpreter of a language complete languages with reversible structured con- S in the language L iff for any S-program p and S- †1 trol flow operators such as Janus and R [9].How- data d and d , ever, none of these languages have tree-structured [[ int]] L(p.d)=d ⇐⇒ [[ p]] S(d)=d . (1) data, and they explicitly limit the number of vari- Following the convention [17], whenever a program ables and constants. is an input into another program, we regard it as Moreover, the reversibility of R-WHILE will be the corresponding data representation. For exam- shown from a new viewpoint, namely by using its ple, p on the right-hand side is an S-program text, denotational semantics. This simplifies the proof whereas p on the left-hand side is a representation of this defining property as compared to the pre- of the text as L-data (e.g., as tree-structured data). vious approach used for the reversible language The language S is the source language,andL is Janus [35]. the implementation language of int. If the source The work presented here is part of a larger ef- language and the implementation language are the fort on advancing reversible computing systems on same, S = L; then, int is a self-interpreter. all levels, including the design and physical realiza- tion of reversible logic circuits [8][29][25], reversible 2. 2 Reversible Interpreter computer architectures [4][28], and programming The usual definition of an interpreter in Eq. (1) languages and abstract machines [1][20][22]. does not carry over to interpreters written in a re- To demonstrate our results, a complete online versible language. Let us look at this surprising interpreter for R-WHILE, an implementation of the and important point more closely. Suppose that linear-time reversible self-interpreter in R-WHILE-M, the implementation language L is a reversible lan- and the program inverter are available from http: guage, which means that all L-programs compute //tetsuo.jp/rwhile-playground/. injective functions. Thus, for all L-programs p and data d1, d2,wehave L L ⇒ . 2 Standard vs. Reversible Interpreters [[ p]] (d1)=[[p]] (d2)= d1 = d2 (2) That is, whenever the output of two applications We define the notion of a reversible interpreter of the same program is identical, so must be their and its efficiency. We find the fundamental differ- input. In particular, consider the L-program int, ences between standard and reversible interpreters which computes an injective function because of the already on this abstract level and even more when reversibility of L. For all S-programs p , p and data we later consider the actual construction of re- 1 2 versible interpreters. We begin by recalling the standard definition of an interpreter and then dis- †1 Following the notational convention [17], we omit cuss the properties of reversible interpreters. the outermost brackets of data if it appears as the argument of a semantic functions, e.g., we write We use the notation presented in [17]: Programs [[ int]] L(p.d) instead of [[int]] L((p.d)). 161 Information and Media Technologies 11: 160-180 (2016) reprinted from: Computer Software 33(3): 108-128 (2016) © Japan Society for Software Science and Technology d,wehave A reversible interpreter that does not require any L L ⇒ . [[ int]] (p1.d)=[[int]] (p2.d)= (p1.d) = (p2.d) output in addition to the representation of the pro- (3) gram and its output is said to be functionally clean. This implies that the program representation of the Thus, an interpreter that returns an extra trace is two S-programs is textually identical: p1 = p2.Us- not functionally clean. S ing this implication and Eq. (1), we get [[p1]] (d)= S ⇒ [[ p2]] (d)= p1 = p2 from Eq. (3). That is, S- 2. 3 Running Time Function programs that compute the same result for some In analogy to the standard terminology, the effi- d must have the same program representation as ciency of programs written in a reversible language the L-data argument for int. However, source lan- L is defined by a running time function L guages that do satisfy this condition are too re- time : L-programs → (L-data → N⊥), (5) L strictive and not very expressive. For example, where timep(d) is the number of steps to compute p either the injective function f1(x)=(x.nil) or with the input d, provided the computation termi- f2(x)=(nil.x) cannot be computed in such a lan- nates; otherwise, undefined ⊥.WedenoteN ∪{⊥} guage since f1(nil)=f2(nil), and the programs by N⊥ (see Sect. 3. 3). implementing f1 and f2 will not be syntactically Finally, the definition of an efficient (i.e., linear- equivalent. time) reversible interpreter in the sense of Jones co- The issue described above cannot be avoided incides with the standard case [17].

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    21 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us