Detection and optimization of functional computations in Prolog

  • Saumya K. Debray
  • David S. Warren
Session 5a: Program Analysis
Part of the Lecture Notes in Computer Science book series (LNCS, volume 225)


While the ability to simulate nondeterminism and return multiple outputs for a single input is a powerful and attractive feature of Prolog, it is expensive both in time and space. Since Prolog programs are very often functional, i.e. do not produce more than one distinct output for a single input, this overhead is especially undesirable. This paper describes how a program may be analyzed statically to determine which literals and predicates are functional, and how the program may then be optimized using this information. Our notion of “functionality” subsumes the notion of “determinacy” that has been considered by various researchers. Our algorithms are less reliant on features such as cut, and thus extend more easily to parallel execution strategies than others that have been proposed.


Logic Program Mutual Exclusion Choice Point Prolog Program Closed Term 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

7. References

  1. 1.
    M. Bruynooghe, “Adding Redundancy to Obtain More Reliable and More Readable Prolog Programs”, in Proc. 1st. Int. Logic Programming Conference, Marseille, France, 1982.Google Scholar
  2. 2.
    M. Bruynooghe and L. M. Pereira, “Deduction revision by intelligent backtracking”, in Implementations of Prolog, J. A. Campbell, (ed.), Ellis Horwood Ltd., Chichester, 1984.Google Scholar
  3. 3.
    J. Chang and A. M. Despain, “Semi-Intelligent Backtracking of Prolog Based on Static Data Dependency Analysis”, in Proc. 1985 Symposium on Logic Programming, Boston, July 1985, 10–21.Google Scholar
  4. 4.
    K. L. Clark, “Negation as Failure”, in Logic and Data Bases, H. Gallaire and J. Minker, (eds.), Plenum Press, New York, 1978.Google Scholar
  5. 5.
    S. K. Debray, “Detection and Optimization of Functional Computations in Prolog”, Technical Report #85/020, Dept. of Computer Science, SUNY at Stony Brook, Stony Brook, NY, Aug. 1985.Google Scholar
  6. 6.
    S. K. Debray, “Automatic Mode Inference for Prolog Programs”, Technical Report #85/019, Department of Computer Science, SUNY at Stony Brook, Stony Brook, NY, June 1985.Google Scholar
  7. 7.
    S. Haridi and A. Ciepielewski, “An Or-Parallel Token Machine”, TRITA-CS-8303, Dept. of Telecommunication Systems — Computer Systems, Royal Institute of Technology, Stockholm, May 1983.Google Scholar
  8. 8.
    C. S. Mellish, “The Automatic Generation of Mode Declarations for Prolog Programs”, DAI Research Paper 163, Dept. of Artificial Intelligence, University of Edinburgh, Aug. 1981.Google Scholar
  9. 9.
    C. S. Mellish, “Some Global Optimizations for a Prolog Compiler”, J. Logic Programming, 2, 1 (Apr. 1985), 43–66.Google Scholar
  10. 10.
    A. O. Mendelzon, “Functional Dependencies in Logic Programs”, in Proc. 11th. ACM Int. Conf. on Very Large Data Bases, Stockholm, Sweden, Aug. 1985.Google Scholar
  11. 11.
    R. A. O'Keefe, “On the Treatment of Cuts in Prolog Source-Level Tools”, in Proc. 1985 Symposium on Logic Programming, Boston, July 1985, 73–77.Google Scholar
  12. 12.
    H. Sawamura and T. Takeshima, “Recursive Unsolvability of Determinacy, Solvable Cases of Determinacy and Their Applications to Prolog Optimization”, in Proc. 1985 Symposium on Logic Programming, Boston, July 1985, 200–207.Google Scholar
  13. 13.
    R. Venken, “A Prolog Meta-Interpreter for Partial Evaluation and its Application to Source-to-Source Transformation and Query Optimization”, in Proc. ECAI 84,.Google Scholar
  14. 14.
    D. H. D. Warren, “Implementing Prolog — Compiling Predicate Logic Programs”, Research Reports 39 and 40, Dept. of Artificial Intelligence, University of Edinburgh, 1977.Google Scholar
  15. 15.
    D. H. D. Warren, “An Abstract Prolog Instruction Set”, Technical Note 309, SRI International, Menlo Park, CA, Oct. 1983.Google Scholar
  16. 16.
    D. S. Warren, M. Ahamad, S. K. Debray and L. V. Kale, “Executing Distributed Prolog Programs on a Broadcast Network”, Proc. 1984 Int. Symp. on Logic Programming, Atlantic City, New Jersey, Feb. 1984.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1986

Authors and Affiliations

  • Saumya K. Debray
    • 1
  • David S. Warren
    • 1
  1. 1.Department of Computer ScienceState University of New York at Stony BrookStony Brook

Personalised recommendations