Prolog Tutorial

De Augusto Baffa Wiki
Revisão de 09h28min de 28 de dezembro de 2020 por Abaffa (discussão | contribs)
Ir para navegação Ir para pesquisar
Outros idiomas:
English • ‎português do Brasil

Este material é uma tradução (com pequenas adaptações e atualizações) do material original publicado pelo professor Dr. John R. Fisher, Ph.D., professor emérito na California State Polytechnic University, Pomona, com sua autorização concedida em 14 de outubro de 2020. Todo o conteúdo está sendo revisado pelo professor Dr. Augusto Baffa, D.Sc., professor do Departamento de Informática da Pontifícia Universidade Católica do Rio de Janeiro (PUC-Rio) que também deverá adicionar novos exemplos com conectores para programas em Python.

Veja todo o conteúdo deste tutorial consultando o sumário.


Introduction

Prolog is the major example of a fourth generation programming language supporting the declarative programming paradigm. The Japanese Fifth-Generation Computer Project, announced in 1981, adopted Prolog as a development language, and thereby focused considerable attention on the language and its capabilities. The programs in this tutorial are written in "standard" (University of) Edinburgh Prolog, as specified in the classic Prolog textbook by authors Clocksin e Mellish (1981, 1992)[1]. The other major kind of Prolog is the PrologII family of Prologs which are the descendants of Marseille Prolog. The reference to Giannesini, et.al. (1986)[2] uses a version of PrologII. There are differences between these two varieties of Prolog; part of the difference is syntax, and part is semantics. However, students who learn either kind of Prolog can easily adapt to the other kind.

This tutorial is intended to be used to help learn the essential, basic concepts of Prolog. The sample programs have been especially chosen to help promote the use of Prolog programming in an artificial intelligence course. Lisp and Prolog are the most frequently used symbolic programming languages for artificial intelligence. They are widely regarded as excellent languages for "exploratory" and "prototype programming".


Chapters

For a complete view of all content, see the table of contents.

  • Chapter 1 explains the Prolog programming environment for the beginner.
  • Chapter 2 explains Prolog syntax and many essentials of Prolog programming through the use of carefully chosen sample programs. The sample programs are arranged to guide the student through the development of Prolog programs that are constructed in a top-down, declarative fashion. Care has been taken to cover Prolog programming techniques that are very useful in an artificial intelligence course. In fact, this primer can serve as a convenient, small, concise Prolog introduction for such a course. Semantic issues have been addressed by introducing early the concept of a program clause tree that is used to define in an abstract way what are supposed to be the consequences of a Prolog program specification. The author believes this to be a viable way to promote the basic semantic issues of software verification for Prolog programming. The last section of this chapter introduces an example that shows that Prolog can be effectively used to give careful, precise specifications of systems, contrary to its usual reputation as being hard to document because it is easy to use as an exploratory programming tool.
  • Chapter 3 explains the operation of the underlying inference engine of Prolog. Chapter 3 should be first read after the student has studied two or three of the sample programs in Chapter 2. The last section in this chapter introduces Prolog meta-interpreters.
  • Chapter 4 gives an outlined view of the major built-in predicates of Prolog, many of which are exemplified in Chapter 2.
  • Chapter 5 gives an outline for developing A* search programs in prolog. Section 5.3 has an αβ search program for the game of tic tac toe.
  • Chapter 6 presents a unique and extensive presentation of a logic meta-interpreter for normal logical rulebases. {Note 9/4/2006: I have edited this chapter heavily, and the section links are all new.}
  • Chapter 7 gives an introduction to Prolog's built-in grammar parser generator, and a brief overview of how Prolog can be used to parse English (natural language) sentences. Also, there is a section covering the construction of simple idiomatic natural language interfaces to programs.
  • Chapter 8 shows how to implement varios prolog prototypes. A new section (§8.4) develops an interactive connection between prolog (inference engine) and Java (GUI) to play tic tac toe. The simple connection model is quite widely adaptable and applicable.


Final Author's Notes

Earlier versions of portions of this tutorial date back to 1988. The introductory material was originally used to help explain a Prolog interpreter developed by the author (no longer available) for use in his courses. The author believes that the introductory material, gathered together in the form given here might be very useful for the student who wants a quick, but well-tailored, introduction to Prolog

For fuller treatments of Prolog the student is advised to see the textbooks by Clocksin e Mellish (1981,1992)[1], by O'Keefe (1990)[3], by Clocksin (1997[4], 2003[5]), or by Sterling e Shapiro (1986)[6].

For excellent historical notes regarding Prolog and natural language processing using Prolog the text by Pereira e Shieber (1987)[7] is recommended.


Professor J.R. Fisher

Pomona, California

1988-2019


References

  • A Prolog Compendium (pdf) by Marc Bezem:This is an excellent conceptual overview of the Prolog suitable for the logical programming component of a Principles of Programming Languages course.

  1. Appel, K.R., and Haken, W., Every planar map is four colorable, Bull. Am. Math. Soc., vol. 82, pp. 711-712, 1976.
  2. Apt, K., and Etalle, S., On the Unification Free Prolog Programs, Computer Science/Department of Software Technology, Report CS-R9331, May 1993.
  3. Baader, and F., Snyder, W., Unification Theory, Chapter 8 of Handbook of Automated Reasoning, edited by Alan Robinson and Andrei Voronkov, Elsevier Science Publishers , 2001.
  4. Bratko, I., Prolog Programming for Artificial Intelligence, Addison-Wesley International Computer Science Series, 1986.
  5. Campbell, J.A., ed., Implementations of Prolog, Wiley, 1984.
  6. Chang, C., and Lee, R. C., Symbolic Logic and Mechanical Theorem Proving, Academic Press, 1973.
  7. Clocksin, W.F., and Mellish, C.S., Programming in Prolog, Springer-Verlag, 1981, 1992.
  8. Clocksin, W.F., Cause and Effect: Prolog programming for the working programmer, Springer-Verlag, 1997.
  9. Clocksin, W.F., Programming in Prolog: using the ISO standard , Springer-Verlag, 2003.
  10. Covington, M. A.,Nute, D., and Vellino, A. Prolog Programming in Depth, Scott, Foresman and Company, Glenview, IL, London, 1988.
  11. DeGroot, D., and Lindstrom, G., Logic Programming, Relations, and Equations, Prentice- Hall, 1986.
  12. Fisher, J.R., Semantic trees for disjunctive logic programs, Intelligent Systems, Proc. Third Golden West International Conference, ed. E.A. Yfantis, pp.291-305, Klewer Academic Publishers, 1995.
  13. Fisher, J.R., Logic program based action specifications, Proc. 1995 Symposium on Applied Computing (SAC'95), Nashville, Tenn., pp.248-52.
  14. Fisher, J.R., and Tran, L., A Visual Logic, Proc. 1996 Symposium on Applied Computing (SAC'96), Philadelphia, Pa., pp.17-21.
  15. Gazdar, G., and Mellish, C., Natural Language Processing in Prolog, Addison-Wesley, 1989.
  16. Giannesini, F, Kanoui, H, Pasero, R., and van Caneghem, M, Prolog, Addison-Wesley International Computer Science Series, 1986.
  17. Green, C., Theorem-proving by resolution as a basis for question-answering systems, in B. Meltzer and D. Michie, eds., Machine Intelligence 4, 183-205, Edinburgh University press, 1968.
  18. Kowalski, R.A., Logic for problem solving, DCL Memo 75, Department of Artificial Intelligence, University of Edinburgh, Scotland, 1974.
  19. Kowalski, R.A., Logic for Problem Solving, North Holland, 1979.
  20. Kowalski, R.A., and Kuehner, D., Linear Resolution with selection function, Artificial Intelligence, (2) 227-60, 1971.
  21. Lloyd, J.W., Foundations of Logic Programming, Springer-Verlag, 1984, 2nd ed. 1987.
  22. Nilsson, N., Principles of Artificial Intelligence, Tioga, 1980.
  23. O'Keefe, Richard A.,The Craft of Prolog, MIT Press, 1990.
  24. Pereira, Fernando C.N., and Shieber, Stuart M., Prolog and Natural-Language Analysis, CSLI, 1987.
  25. Robinson, J.A., A machine-oriented logic based on the resolution principle, Journal A.C.M., (12) 23-44, 1965.
  26. Rowe, W.C., AI Through Prolog, Prentice Hall, 1988.
  27. Shoham, Y., Artificial Intelligence Techniques in Prolog, Morgan Kaufmann Publishers, 1994.
  28. Sterling, Leon, and Shapiro, Ehud, The Art of Prolog, MIT Press, 1986.
  29. Van Le, T., Prolog Programming, Wiley, 1993.
  30. Winston, Patrick Henry, Artificial Intelligence, 2nd. ed., Addison-Wesley, 1984.
  31. Winston, P.H., and Horn, P., Lisp, Addison-Wesley, 1985.


See also


References

  1. 1,0 1,1 Clocksin, W.F., and Mellish, C.S., Programming in Prolog, Springer-Verlag, 1981, 1992.
  2. Giannesini, F, Kanoui, H, Pasero, R., and van Caneghem, M, Prolog, Addison-Wesley International Computer Science Series, 1986.
  3. O'Keefe, Richard A.,The Craft of Prolog, MIT Press, 1990.
  4. Clocksin, W.F., Cause and Effect: Prolog programming for the working programmer, Springer-Verlag, 1997
  5. Clocksin, W.F., Programming in Prolog: using the ISO standard , Springer-Verlag, 2003.
  6. Sterling, Leon, and Shapiro, Ehud, The Art of Prolog, MIT Press, 1986.
  7. Pereira, Fernando C.N., and Shieber, Stuart M., Prolog and Natural-Language Analysis, CSLI, 1987.