## Running Programs Backwards: the Logical Inversion of Imperative (2003)

Citations: | 13 - 0 self |

### BibTeX

@TECHREPORT{Ross03runningprograms,

author = {Brian J. Ross},

title = {Running Programs Backwards: the Logical Inversion of Imperative},

institution = {},

year = {2003}

}

### OpenURL

### Abstract

Imperative programs can be inverted directly from their forward-directed program code with the use of logical inference. The relational semantics of imperative computations treats programs as logical relations over the observable state of the environment, which is taken to be the state of the variables in memory. Program relations denote both forward and backward computations, and the direction of the computation depends upon the instantiation pattern of arguments in the relation. This view of inversion has practical applications when the relational semantics is treated as a logic program. Depending on the logic programming inference scheme used, execution of this relational program can compute the inverse of the imperative program. A number of nontrivial imperative computations can be inverted with minimal logic programming tools.

### Citations

3831 | Introduction to Automata Theory, Languages and Computation - HOPCROFT, ULLMAN - 1979 |

3399 | Communicating sequential process - Hoare - 1985 |

1359 | An Axiomatic Basis for Computer Programming
- Hoare
- 1969
(Show Context)
Citation Context ...perative programming languages and the formal derivation of programs written in them. A host of different programming logics have been suggested, two famous examples being Hoare's axiomatic semantics =-=[Hoa69]-=- and Dijkstra's predicate transformers [Dij75]. A newer logic is Hehner's relational semantics [Heh84a, Heh84b]. Hehner's logic is appealing because it reduces the distinction between the programming ... |

466 |
The Science of Programming
- Gries
- 1981
(Show Context)
Citation Context ...present the inverses of atomic operations [Lee86]. The inversions of imperative and logic programs are discussed in the following sections. 2.2 Imperative program inversion Dijkstra [Dij82] and Gries =-=[Gri81]-=- introduced the step-wise derivation of inverted imperative programs from forward-executing algorithms, and others have investigated this idea further [CU90, vW91]. Consider a program that has a compu... |

455 |
Logical reversibility of computation
- Bennett
- 1973
(Show Context)
Citation Context ... of b = c = 1, both the test constraints as0 and as0 will be valid. A CLP interpreter can then deduce that these constraints reduce to a = 0. Bennett discusses logical reversibility of computation in =-=[Ben73]-=-, in which he compares biochemical DNA reactions with reversible computations: [...] we can see that here the reactions form a branching structure, with a main trunk corresponding to the desired compu... |

413 |
Guarded commands, nondeterminacy and formal derivation of programs
- Dijkstra
- 1975
(Show Context)
Citation Context ...derivation of programs written in them. A host of different programming logics have been suggested, two famous examples being Hoare's axiomatic semantics [Hoa69] and Dijkstra's predicate transformers =-=[Dij75]-=-. A newer logic is Hehner's relational semantics [Heh84a, Heh84b]. Hehner's logic is appealing because it reduces the distinction between the programming and specification languages -- both are direct... |

248 |
Seminumerical Algorithms
- Knuth
- 1998
(Show Context)
Citation Context ...gorithm P This example is used to illustrate how conventional data structures such as arrays can be used within logical inversions. The program in figure 8 is an implementation of Knuth's Algorithm P =-=[Knu81]-=-. Given a permutation of n different integers, the forward program calculates a unique number k (0sk ! n!) based on the relative ordering of integers in the permutation. Executing algorithm P on the p... |

124 |
Algorithm = Logic + Control
- Kowalski
- 1979
(Show Context)
Citation Context ...n to refute Prog [ fQg [Llo87]. 6 The conceptual distinction between a program's declarative semantics and procedural semantics is one of the characterising features of the logic programming paradigm =-=[Kow79]-=-. A logic program has a declarative semantics, which is the program's relational interpretation when the program predicates are interpreted as comprising a first-order Horn clause theory. From the dec... |

121 | Essentials of Logic Programming - Hogger - 1990 |

91 | Predicate logic as a computational formalism - Clark - 1979 |

73 |
The Thermodynamics of Computation, a Review
- Bennett
- 1982
(Show Context)
Citation Context ...rward execution. Hence each forward computation step has an inverse defined for it. Bennett makes a fascinating analogy between reversible computations and the reproductive activity of organic DNA in =-=[Ben82]-=-, in which which forward and reverse DNA reactions are analogous to forward and backward computation steps. 3 Other work using program inversion includes the following. Broy uses program inverses to s... |

70 | The Foundations of Program Verification - Loeckx, Sieber - 1984 |

64 | Invertible cellular automata: a review - Toffoli, Margolus - 1991 |

43 |
SICStus Prolog User's Manual
- Carlsson
- 1988
(Show Context)
Citation Context ...tions of Prolog have control mechanisms which conform to the dynamic state of the inference. For example, SICStus Prolog allows the delaying of goals whose arguments are not sufficiently instantiated =-=[CW88]-=-. This permits the execution of programs which would normally have required an altered computation rule, such as those studied by Shoham and McDermott. Many Prolog utilities, such as those for arithme... |

35 |
An experimental program transformation and synthesis system
- Darlington
- 1981
(Show Context)
Citation Context ...uages, for example, to allow (n : 1) functions to be treated as inverse (1 : n) relations. To this end, program inversions have been introduced to Lisp [Kor81], fold and unfold transformation systems =-=[Dar81], and Hope-=-+ [HH86]. Programming environments often make use of "undo" operations, which represent the inverses of atomic operations [Lee86]. The inversions of imperative and logic programs are discuss... |

25 |
Foundations of Logical Programming, 2nd Ed
- Lloyd
- 1987
(Show Context)
Citation Context ...ame head name (we assume the arity is consistent). A goal clause ": \Gamma G 1 ; :::; Gm :" represents a query Q for the logic program, and is solved by applying SLDNF resolution to refute P=-=rog [ fQg [Llo87]-=-. 6 The conceptual distinction between a program's declarative semantics and procedural semantics is one of the characterising features of the logic programming paradigm [Kow79]. A logic program has a... |

24 | Logic: A Foundation for Computer Science - Sperschneider, Antoniou - 1991 |

23 |
A formal approach to undo operations in programming languages
- Leeman
- 1986
(Show Context)
Citation Context ...uced to Lisp [Kor81], fold and unfold transformation systems [Dar81], and Hope+ [HH86]. Programming environments often make use of "undo" operations, which represent the inverses of atomic o=-=perations [Lee86]-=-. The inversions of imperative and logic programs are discussed in the following sections. 2.2 Imperative program inversion Dijkstra [Dij82] and Gries [Gri81] introduced the step-wise derivation of in... |

20 |
Program inversion
- Dijkstra
- 1979
(Show Context)
Citation Context ...erations, which represent the inverses of atomic operations [Lee86]. The inversions of imperative and logic programs are discussed in the following sections. 2.2 Imperative program inversion Dijkstra =-=[Dij82]-=- and Gries [Gri81] introduced the step-wise derivation of inverted imperative programs from forward-executing algorithms, and others have investigated this idea further [CU90, vW91]. Consider a progra... |

18 | The Logic of Programming - Hehner - 1984 |

18 |
Function inversion
- Harrison
(Show Context)
Citation Context ... to allow (n : 1) functions to be treated as inverse (1 : n) relations. To this end, program inversions have been introduced to Lisp [Kor81], fold and unfold transformation systems [Dar81], and Hope+ =-=[HH86]. Programm-=-ing environments often make use of "undo" operations, which represent the inverses of atomic operations [Lee86]. The inversions of imperative and logic programs are discussed in the followin... |

16 | Program inversion: more than fun - Chen, Udding - 1988 |

12 |
The inversion of functions defined by turing machines
- McCarthy
- 1956
(Show Context)
Citation Context ...ed computational inversions from the standpoint of computing and testing Turing machine computations over the enumerated values of the program's data, in essence exhaustively searching for an inverse =-=[McC56]-=-. Although this technique will find an inverse if it exists, the Halting Problem implies that it is impossible for the program to determine if one does not exist. In addition, exhaustive enumeration i... |

12 | C.J.: â€œGrammar-Related Transformations of Logic Programs - Brough, Hogger - 1991 |

11 | de Snepscheut. What computing is all about - van - 1993 |

10 | Predicative programming Part I - Hehner - 1984 |

8 | de Snepscheut. Inorder traversal of a binary tree and its inversion - Gries, van - 1990 |

7 | Inversion of applicative programs
- Korf
- 1981
(Show Context)
Citation Context ...declarative power of functional programming languages, for example, to allow (n : 1) functions to be treated as inverse (1 : n) relations. To this end, program inversions have been introduced to Lisp =-=[Kor81], fold and-=- unfold transformation systems [Dar81], and Hope+ [HH86]. Programming environments often make use of "undo" operations, which represent the inverses of atomic operations [Lee86]. The inversi... |

6 |
Consequence verification of flowcharts
- Clark, Emden
- 1981
(Show Context)
Citation Context ...n, program refinement, and program verification, are modellable in this logical system. Clark and van Emden apply the Horn clause subset of first-order logic towards modelling imperative computations =-=[CvE81]-=-. This semantics is a relational semantics like Hehner's, but restricted to Horn clause logic. An advantage of restricting the logical model in this way is that logic programming models of computation... |

6 | And/Or Programs: a New Approach to Structured Programming
- Harel
- 1980
(Show Context)
Citation Context ...retical problem for many algorithms, and probably impossible for NP-complete ones. The need for the angelic nondeterminism operator can be seen when one considers the AND/OR tree model of computation =-=[Har80]-=-. The left-most diagram in figure 1 shows some computation paths for different inputs of a terminating imperative program. Each arc represents the modification of the computation state. Execution begi... |

6 | Program inversion in the refinement calculus - Wright - 1991 |

4 |
The partial evaluation of imperative programs using prolog
- Ross
- 1988
(Show Context)
Citation Context ... logic programming models of computation can be applied to the semantic descriptions of programs. Ross applies this idea by using Horn clause logic in a source-to-source program transformation system =-=[Ros89]-=-. Imperative programs have Horn clause descriptions transliterated for them (see figure 2), which are treated as pure Prolog programs. Each predicate tuple has two arguments -- the initial and final s... |

3 |
Invertibility of logic programs
- Sickel
- 1979
(Show Context)
Citation Context ...ent within a program can be ascertained, and the control scheme appropriately adapted. Sickel studies the modes of predicate arguments in order to determine the computability of particular inversions =-=[Sic79]-=-. 3 Logically computing imperative inverses This section gives an informal illustration of how logic programming can be used to invert imperative algorithms. Given an imperative program to be inverted... |

3 |
Metalogical control for logic programs
- Vasak, Potter
- 1985
(Show Context)
Citation Context ...his information. This strategy is suggested by Vasak and Potter, in which additional termination conditions are encoded within logic programs to stop execution down fruitless paths of the computation =-=[TJ85]-=-. Of course, knowing how to control inference in such a manner is not always feasible -- knowing such heuristics for particular algorithms would resolve many outstanding unsolved mathematical and comp... |

2 |
Derivation of invariant assertions during program development by transformation
- Broy, Krieg-Bruckner
- 1980
(Show Context)
Citation Context ...putation steps. 3 Other work using program inversion includes the following. Broy uses program inverses to simplify the derivation of particular types of recursive structures during program synthesis =-=[BKB80]-=-. Program inversion is useful for enhancing the declarative power of functional programming languages, for example, to allow (n : 1) functions to be treated as inverse (1 : n) relations. To this end, ... |

2 |
Directed relations and inversion of prolog programs
- Shoham, McDermott
- 1984
(Show Context)
Citation Context ...too inefficient to be practical in many applications. Shoham and McDermott experiment with inverting logic programs by deriving meta-- interpreters incorporating a number of different control schemes =-=[SM84]-=-. Some logic programs require slightly modified inference strategies in order to infer their inverses. For example, the inverses of some logic programs is obtained by reversing the order of goal selec... |

1 |
The Treatment of Loops in Logic Programming
- Brough, Hogger
- 1986
(Show Context)
Citation Context ...o encode abduction in the inverted logical semantics itself. Brough and Hogger describe a logic program transformation which parallels the Greibach-Foster transformation used in formal grammar theory =-=[BH86]-=-. Given a logic program which matches the schema on the left, they propose the following logically sound transformation: P : \Gamma T : P : \Gamma P; R: =) P 0 : \Gamma T ; S: [1] S: S : \Gamma R; S: ... |

1 |
Programming in Prolog (3rd ed
- Clocksin, Mellish
- 1987
(Show Context)
Citation Context ... (ns0), where H; G i are atoms of aritys0. The logic program syntax normally adopted for such clauses is "H : \Gamma G 1 ; :::; G n :", where H is the clause head, and the goals G i comprise=-= the body [CM87]-=-. Clauses with non-empty bodies are rules, while those with empty bodies are facts. A procedure or predicate is a collection of clauses labelled by the same head name (we assume the arity is consisten... |

1 |
The Logical Inversion of Imperative Computations
- Ross, Wilk
- 1989
(Show Context)
Citation Context ...that can compute imperative program inverses. Some example program inversions are given in section 4. A discussion concludes the paper in section 5. 1 1 A preliminary version of this work appeared in =-=[RW89]-=-. 2 2 The inversion problem 2.1 General overview Inversion is a fundamental concept in mathematics and theoretical computer science. Function inversion is the process of deriving for some 1 : 1 functi... |

1 |
Program inversion in the refinement calculus. Information Processing letters, 37:95--100
- Wright
- 1991
(Show Context)
Citation Context ...the program's code and specification. Von Wright suggests that program S \Gamma1 is the inverse of program S under precondition P if the following total correctness formula holds for all predicates Q =-=[vW91]-=-: (PsQ) [S; S \Gamma1 ] Q 4 We can think of S \Gamma1 as reversing or undoing the computation done by S before it. As long as all the constituent \Gamma are invertible, so is S: S \Gamma1 (oe) , f \Ga... |