Logic programming languages have several very attractive features, such as separation of program logic from control, declarative reading of programs, and ease of understanding and maintenance. Despite this, however, the pragmatic problem of efficiency has hampered the widespread acceptance of such languages as general-purpose programming languages, and has led to the proliferation of "impure" language features whose use compromises precisely those properties of these languages that made them attractive in the first place.In this dissertation, we take the view that rather than leave the burden of writing efficient programs to the programmer, and force him to deal with impure language features, it is preferable to have the system perform such optimizations for him. It is argued that the model theory of first order logic, traditionally used to specify the semantics of logic programs, is too weak to allow us to reason about the computational behaviour of programs. A classical denotational semantics is developed for Prolog, and notions of strong and weak program equivalence are defined. A general framework for dataflow analysis of logic programs, based on this semantics, is developed. Several analysis problems considered in the literature, such as mode inference, data dependency analysis, type inference, functor propagation, and dead and unreachable code detection, are shown to be instances of this framework. The property of functionality, related to but more general than that of determinacy, is discussed, and an algorithm given for its inference. Several optimizing transformations of logic programs based on these analyses are discussed. Finally, some experimental results are given, showing the effects of such transformations on the performance of programs. These results support our view that it is possible, in general, to take "pure" logic programs and have an intelligent compiler generate code that is quite efficient, thereby achieving efficiency without having to sacrifice the advantages of purity.
Recommendations
Compilation of Disjunctive Logic Programs Using an Extended WAM
COMPSAC '96: Proceedings of the 20th Conference on Computer Software and ApplicationsIn this paper, we show that disjunctive logic programs can be efficiently compiled to an extended version of Warren's Abstract Machine (WAM). In this compilation, we use Plaisted's Modified Problem Reduction Format (MPRF) as the basic proof procedure. ...
An improved proof-theoretic compilation of logic programs
In prior work, we showed that logic programming compilation can be given a proof-theoretic justification for generic abstract logic programming languages, and demonstrated this technique in the case of hereditary Harrop formulas and their linear ...
Compilation of Nonprocedural Specifications into Computer Programs
The paper describes the compilation of a program specification, written in the very high level nonprocedural MODEL language, into an object, PL/1 or Cobol, procedural language program. Nonprocedural programming languages are descriptive and devoid of ...