290 likes | 497 Views
Reversible Flowchart Languages and the Structured Reversible Program Theorem. Tetsuo Yokoyama 1 Holger Bock Axelsen 2 Robert Glück 2 1 Graduate School of Information Science Nagoya University 2 Department of Computer Science University of Copenhagen. [ICALP2008]. GRACE BDX’08 . Overview.
E N D
Reversible Flowchart Languages and the Structured Reversible Program Theorem Tetsuo Yokoyama1 Holger Bock Axelsen2 Robert Glück2 1Graduate School of Information ScienceNagoya University 2Department of Computer ScienceUniversity of Copenhagen [ICALP2008] GRACE BDX’08
Overview • Reversible unstructured/structured flowcharts • Reversible structured program theorem • Reversible flowcharts are r-Turing complete • Injectivizing irreversible flowcharts • Conclusion
Reversible flowcharts 1 (machine code) = altered stuff stuff
Reversible flowcharts 2 • Steps must be reversible • x := y is not allowed, previous value unknown • x ^= y (short for x := xXORy) is allowed, previous value computable • In general, reversible updates [CSR07,CF08] • Assertions are added to join points • Removes non-determinism from the merging of control flow • Not injective in general (like expressions in tests) • Well-formed iff unique entry and exit arcs
Structured reversible flowcharts (high-level programming) = new stuff stuff
Aside: Inversion Local and fast
Overview • Reversible unstructured/structured flowcharts • Reversible structured program theorem • Reversible flowcharts are r-Turing complete • Injectivizing irreversible flowcharts • Conclusion
Why structured programs (again)? • “Goto considered harmful” also for reversible programming • Original Böhm-Jacopini proof not valid in reversible setting • Reversible programming is largely uncharted land, and has unfamiliar features
Structured reversible program theorem • Theorem: For every (unstructured) reversible flowchart program, there is a functionally equivalent structured reversible flowchart program. • Proof:Simluate control flow across one node at a time. Label each of n arcs by li, assuming entry arc is l1 and exit arc is ln. Then sequentially test whether control is on an arc, executing the subsequent node if applicable.
Structured reversible program theorem: Main loop xi : true if control flow is on arc li
Structured reversible program theorem: Step Pi,jxi ^= true ; xj^= true Moves control from arc lito arc lj
Overview • Reversible unstructured/structured flowcharts • Reversible structured program theorem • Reversible flowcharts are r-Turing complete • Injectivizing irreversible flowcharts • Conclusion
r-Turing completeness • Definition: A programming language is r-Turing completeiff it can simulate any reversible Turing machinecleanly, without garbage/history stack.
Aside: Cleanliness • Why clean simulation? Because injective and injectivized functions are different! • Example: Reversibly multiplying primes p1* p2 is easy with garbage (say, p1,) but equivalent to factoringif clean (because RTMs are time reversible.) • Lesson: Do not confuse Bennett’s injectivizedmachines withgeneral RTMs!
Reversible Turing machines • Definition: A Turing machine is reversible iff it is fwd and bwd deterministic. • Notation:Quadruple format for • symbolrules: <q1,s1,s2,q2> • moverules: <q1,/,d,q2> [Bennett73]
r-Turing completeness of RFCL • Theorem: Reversible flowcharts are r-Turing complete. • Proof:Simulate tape as pair of (here infinite, but finite works) stacks and a single value for the symbol under the r/w head. Addbooleansfor the states and test for rule applicability sequentially.
r-Turing completeness: Tape r/w Tape s Stacks right left
r-Turing completeness: symbol rule Qq1,q2q ^= q1 ; q ^= q2 Ss1,s2s ^= s1; s ^= s2
r-Turing completeness: move rule M-pushs right ; pop s left M+pushs left ; pop s right Q.E.D.
Overview • Reversible flowcharts • Reversible structured program theorem • Reversible flowcharts are r-Turing complete • Injectivizing irreversible flowcharts • Conclusion
Injectivizing irreversible flowcharts • Problem: In reversible languages exactly the injective computable functions are computable • Solution:Transform the program into an injective reversible version that computes the same function along with some garbage data • Only necessary for non-injective functions • History: Landauer embedding, Bennett's method
Injectivization theorem • Theorem: For every classical flowchart program computing f(x) as output, there is a reversible flowchart computing f(x) as part of its output. • Proof:Add a historystack h to the state. For every irreversible operation we save the data necessary for bwd determinism on this stack.
Injectivization: Step • Steps are assumed to be assignments of the form x := e • Replace x := e with push x h; x ^= e[top h / x] Q.E.D.
Overview • Reversible flowcharts • Reversible structured program theorem • Reversible flowcharts are r-Turing complete • Injectivizing irreversible flowcharts • Conclusion
Conclusion • Reversible flowchartsintroduced • Structure is free, even for reversible programs • Injectivization is possible, giving Turing completeness in practice • r-Turing completeness, as powerful as reversible programming can get wrt computability • [ICALP08] : T Yokoyama, HB Axelsen, R Glück: “Reversible Flowchart Languages and the Structured Reversible Program Theorem”, Automata, Languages and Programming (Proc.), LNCS 5126, pp 258-270, 2008