skip to main content
article
Open Access

Functional computations in logic programs

Published:01 July 1989Publication History
Skip Abstract Section

Abstract

Although the ability to simulate nondeterminism and to compute multiple solutions for a single query is a powerful and attractive feature of logic programming languages, it is expensive in both time and space. Since programs in such languages are very often functional, that is, they do not produce more than one distinct solution for a single input, this overhead is especially undesirable. This paper describes how programs 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 algorithm is less reliant on language features such as the cut, and thus extends more easily to parallel execution strategies, than others that have been proposed.

References

  1. 1 BRUYNOOGHE, M., AND PEREIRA, L. M. Deduction revision by intelligent backtracking. In Implementations of Prolog, J. A. Campbell, Ed. Ellis Horwood Ltd., Chichester, 1984, pp. 194-215.Google ScholarGoogle Scholar
  2. 2 BUTLER, R., LUSK, E. L., OLSON, R., AND OVERBEEK, R.A. ANLWAM: A parallel implementation of the Warren abstract machine. Intern. Rep., Argonne National Laboratory, Chicago, Ill., 1986.Google ScholarGoogle Scholar
  3. 3 CHANG, J., AND DESPAIN, A.M. Semi-intelligent backtracking of Prolog based on static data dependency analysis. In Proceedings of the 1985 Symposium on Logic Programming (Boston, Mass., Feb. 1985). IEEE, Washington, D.C., 1985, pp. 10-21.Google ScholarGoogle Scholar
  4. 4 CLARK, $. r. Negation as failure. In Logic and Data Bases, H. Gallaire and J. Minker, Eds. Plenum, New York, 1978.Google ScholarGoogle Scholar
  5. 5 CONERY, J.S. Parallel Execution of Logic Programs. Kluwer, The Netherlands, 1987. Google ScholarGoogle Scholar
  6. 6 DEBRAY, S.K. The SB-Prolog system, version 2.3.2: A user manual. Tech. Rep. 87-15, Dept. of Computer Science, Univ. of Arizona, Tucson, Ariz., Dec. 1987. (Revised March 1988.)Google ScholarGoogle Scholar
  7. 7 DEBRAY, S. K., AND MISHRA, P. Denotational and operational semantics for Prolog. J. Logic Program. 5, I (Mar. 1988), 61-91. Google ScholarGoogle Scholar
  8. 8 DEBRAY, S. K., AND WARREN, D.S. Automatic mod.~ inference for logic programs. J. Logic Program. 5, 3 (Sept. 1988), 207-229. Google ScholarGoogle Scholar
  9. 9 DEGROOT, D. Restricted AND-parallelism. In Proceedings of the International Conference on Fifth Generation Computer Systems ICOT, (Tokyo, 1984 ).Google ScholarGoogle Scholar
  10. 10 DERANSART, P., AND MALUSZYNSKI, J. Relating logic programs and attribute grammars. J. Logic Program. 2, 2 (July 1985), 119-156.Google ScholarGoogle Scholar
  11. 11 HAUSMAN, B., CIEPIELEWSKI, A., AND HARIDI, S. Or-parallel Prolog made efficient on shared memory multiproeessors. In Proceedings of the 1987 IEEE Symposium on Logic Programming (San Francisco, Calif., Aug. 1987). IEEE, New York, 191~7, pp. 69-79.Google ScholarGoogle Scholar
  12. 12 HERMENEGILDO, M. V. An abstract machine for resLricted AND-parallel execution of logic programs. In Proceedings of the 3rd International Conlerence on Logic Programming (London, July 14-18, 1986). Springer, New York, 1986, pp. 25-39. (Springer-Verlag LNCS vol. 225.) Google ScholarGoogle Scholar
  13. 13 JONES, N. D., AND MYCROrT, A. Stepwise developmenL of operational and denotational semantics for PROLOG. In Proceedings of the 1984 Internatwnal Symposium on Logic Programming (Atlantic City, N.J., Feb. 6-9, 1984). IEEE, New York, ~.984, pp. 289-298.Google ScholarGoogle Scholar
  14. 14 KALE, L. V. The REDUCE-OR process model for parallel evaluation of logic programs. In Proceedings of the 4th International Conference on Logi( Programming. (Melbourne, May 25-29, 1987). MIT Press, Cambridge, Mass., 1987, pp. 616-632Google ScholarGoogle Scholar
  15. 15 LLOYD, J.W. Foundations of Logic Programming. Springer-Verlag, New York, 1984. Google ScholarGoogle Scholar
  16. 16 MAIER, D. The Theory of Relational Databases. Computer Science Press, Rockville, Md., 1983. Google ScholarGoogle Scholar
  17. 17 MELLISH, C.S. Some global optimizations for a Prok,g compiler. J. Logic Program. 2, I (Apr. 1985), 43-66.Google ScholarGoogle Scholar
  18. 18 MENOELZON, A.O. Functional dependencies in logic programs. In Proceedings of the 11th ACM International Conference on Very Large Data Bases (Stockholm, Aug. 1985). ACM, New York, 1985.Google ScholarGoogle Scholar
  19. 19 NAISH, L. Negation and qnantifiers in NU-Prolog. iln Proceedings of the 3rd International Conference on Logic Programming (London, July 14-18, 1986). Springer-Verlag, New York, 1986, pp. 624-634. (Springer-Verlag LNCS vol. 225.) Google ScholarGoogle Scholar
  20. 20 NAISH, L. Negation and Control in Prolog. LNCS vol. ~38. Springer-Verlag, New York, 1986. Google ScholarGoogle Scholar
  21. 21 O'KEEFE, R.A. On the treatment of cuts in Prolog sou me-level tools. In Proceedings of the 1985 Symposium on Logic Programming (Boston, Mass., Julv 15-18, 1985) IEEE, Washington, D.C., 1985, pp. 73-77.Google ScholarGoogle Scholar
  22. 22 OVERBEEK, R. a., GABRIEL, J., LINDHOLM, W., AND I. USK, E.L. Prolog on multiprocessors. Intern. Rep., Argonne National Laboratory, Chicago, IlL 1985.Google ScholarGoogle Scholar
  23. 23 ROBINSON, J.A. Logic programming--Past, present end future. New Generation Comput. I, 2 (1983).Google ScholarGoogle Scholar
  24. 24 SAWAMURA, $., AND TAKESHIMA, T. Recursive unsob~ability of determinacy, solvable cases of determinacy and their applications to Prolog optimizati(,n. In Proceedings of the 1985 Symposium on Logic Programming (Boston, Mass., July 15-18, 19~5). IEEE, Washington, D.C., 1985, pp. 200-207.Google ScholarGoogle Scholar
  25. 25 VAN EMDEN, M. H., AND KOWALSKI, R.A. The semantics of predicate logic as a programming language. J. ACM 23, 4 (Oct. 1976), 733-742. Google ScholarGoogle Scholar
  26. 26 WARREN, D. $. D. Implementing Prolog--Compiling predicate logic programs. Res. Reps. 39 and 40, Dept. of Artificial Intelligence, Univ. of Edinbul'gh, 1977.Google ScholarGoogle Scholar
  27. 27 WARREN, D. H.D. Efficient processing of interactive relational database queries expressed in logic. In Proceedings of the 7th Conference on Very Large Data Bases (Cannes, Sept. 9-11, 1981). ACM, New York, 1981, pp. 272-281.Google ScholarGoogle Scholar
  28. 28 WARREN, D. $. D. An abstract Prolog instruction set. Tech. Note 309, SRI International, Menlo Park, Calif., Oct. 1983.Google ScholarGoogle Scholar
  29. 29 WARREN, D. $. D. The SRI model for or-parallel execution of Prolog--Abstract design and implementation issues. In Proceedings of the 1987 IEEE Symposium on Logic Programming (San Francisco, Calif., Aug. 31-Sept. 4, 1987). IEEE, New Ycrk, pp. 92-102.Google ScholarGoogle Scholar
  30. 30 WARREN, D. S., AHAMAD, M., DEBRAY, S. K., AND KALE, L.V. Executing distributed Prolog programs on a broadcast network. In Proceedings of the 1984 International Symposium on Logic Programming (Atlantic City, N.J., Feb. 1984). IEEE, Washington, D.C., 1984.Google ScholarGoogle Scholar
  31. 31 WESTPHAL, H., ROBERT, P., CHASSIN, J., AND SYRE, J. The PEPSys model: Combining backtracking, AND- and OR-parallelism. In Proceedings of the 1987 IEEE Symposium on Logic Programming, (San Francisco, Calif., Aug. 31-Sept. 4, 1987). IEEE, New York, 1987, pp. 436-448.Google ScholarGoogle Scholar
  32. 32 WISE, M.J. Epilog: Reinterpreting and extending Prolog for a multiprocessor environment. In Implementations o{ Prolog, J. A. Campbell, Ed. Ellis Horwood Ltd., Chichester, 1984, pp. 341-351.Google ScholarGoogle Scholar

Index Terms

  1. Functional computations in logic programs

              Recommendations

              Reviews

              Francois Aribaud

              Because it is well known that full backtracking is the cause of inefficiency in the execution of Prolog programs, Prolog has a special feature designed to reduce the running time, namely, the highly controversial cut, which is not a logical operation but which conveys certain information to the system. In this paper, the authors start with the observation that programs are often functional: if all alternatives produce the same result, then repeated computation (the gist of backtracking) is unnecessary. Therefore, a prior analysis of the functional components of the program is a major improvement. Because functionality is a matter of semantics, the problem of the exact determination of what is functional is generally undecidable. Instead, the authors look at syntactic functionalities. They describe some rules which, from functional predicates, lead to other functional predicates. An algorithm running in linear time determines these functionalities. One may take advantage of this knowledge and optimize the programs by inserting suitable cuts, the control status of which is then clearly established. The authors note that “some predicates which are actually functional, are inferred to be relational (i.e., not functional).” One may hope that for usual programs the part of the forgotten functional components is small.

              Access critical reviews of Computing literature here

              Become a reviewer for Computing Reviews.

              Comments

              Login options

              Check if you have access through your login credentials or your institution to get full access on this article.

              Sign in

              Full Access

              • Published in

                cover image ACM Transactions on Programming Languages and Systems
                ACM Transactions on Programming Languages and Systems  Volume 11, Issue 3
                July 1989
                137 pages
                ISSN:0164-0925
                EISSN:1558-4593
                DOI:10.1145/65979
                Issue’s Table of Contents

                Copyright © 1989 ACM

                Publisher

                Association for Computing Machinery

                New York, NY, United States

                Publication History

                • Published: 1 July 1989
                Published in toplas Volume 11, Issue 3

                Permissions

                Request permissions about this article.

                Request Permissions

                Check for updates

                Qualifiers

                • article

              PDF Format

              View or Download as a PDF file.

              PDF

              eReader

              View online with eReader.

              eReader