Skip to main content

Some Thoughts on How to Teach Prolog

  • Chapter
  • First Online:
Prolog: The Next 50 Years

Abstract

Prolog, and (Constraint) Logic Programming in general, represent a unique programming paradigm. Prolog has many characteristics that are not present in other styles of programming, and this is one of the reasons why it is taught. At the same time, and precisely because of this uniqueness, teaching Prolog presents some special challenges. In this paper we present some lessons learned over many years of teaching Prolog, and (C)LP in general, mostly to CS college students, at several universities. We address how to show the beauty and usefulness of the language, and also how to avoid some common pitfalls, misconceptions, and myths about it. The emphasis of our discussion is on how, rather than what. Despite some focus on CS college students, we believe that many of the ideas that we propose also apply to teaching Prolog at any other education level.

Partially funded by MICINN projects PID2019-108528RB-C21 ProCode, TED2021-132464B-I00 PRODIGY, and FJC2021-047102-I, by the Comunidad de Madrid program P2018/TCS-4339 BLOQUES-CM, and by the Tezos foundation. The authors would also like to thank the anonymous reviewers for very useful feedback on previous drafts of this paper.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 64.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 84.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    See https://cliplab.org/logalg for a collection of our teaching materials. We would like to thank the many contributors to these materials which have influenced this paper, including Francisco Bueno, Manuel Carro, Isabel García Contreras, Daniel Cabeza, María José García de la Banda, David H. D. Warren, Ulrich Neumerkel, Michael Codish, and Michael Covington.

  2. 2.

    See also other papers in this volume, which address the subject of teaching Prolog to school children [2, 3, 19].

  3. 3.

    A historical note can be useful at this or a later point, saying that this materialization was done by Colmerauer (with colleagues in Marseilles and in collaboration with Kowalski and colleagues in Edinburgh) [4, 14], and was made possible by the appearance of Robinson’s resolution principle [18], Cordell Green’s approach to resolution-based question answering [7], the efficiency of Kowalski and Kuhnen’s SLD resolution [12], Kowalski’s combination of the procedural and declarative interpretations of Horn clauses [11], and the practicality brought about by Warren et al.’s Dec-10 Prolog implementation [17, 23].

  4. 4.

    The directive (an expansion) activates breadth-first execution, which we find instrumental in this part of the course; see also the discussion in Sect. 3.

  5. 5.

    See also [21], in this same volume, for an ample discussion of how to build programs inductively.

  6. 6.

    See also the discussion in Sect. 3 on termination, the shape of the tree, search strategies, etc.

  7. 7.

    And even some LP languages have been proposed that explicitly did not have an operational semantics, such as, e.g., the Goedel language.

  8. 8.

    Clicking on the links is perfectly safe!.

  9. 9.

    See also [1], in this same volume, for another interesting example which can be used similarly.

  10. 10.

    E.g., in Ciao Prolog, in which we have added over time a number of features to facilitate teaching Prolog and (C)LP, one can for example use to run all predicates breadth-first. Also, many Prologs have tabling nowadays.

  11. 11.

    https://prob.hhu.de/w/index.php?title=Why_Prolog%3F.

  12. 12.

    An interesting topic that is however out of our scope here –let’s just say for this discussion that they used “something similar to Erlang.”

  13. 13.

    https://cliplab.org/logalg.

References

  1. Bassiliades, N., Sakellariou, I., Kefalas, P.: Demonstrating multiple prolog programming techniques through a single operation. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 71–81. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_6

  2. Cecchi, L.A., Rodríguez, J.P., Dahl, V.: Logic Programming at Elementary School: why, what and how should we teach Logic Programming to children. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 131–143. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_11

  3. Cervoni, L., Brasseur, J., Rohmer, J.: Simultaneously teaching mathematics and prolog in school curricula: a mutual benefit. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 124–130. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_10

  4. Colmerauer, A.: The birth of prolog. In: Second History of Programming Languages Conference, pp. 37–52. ACM SIGPLAN Notices (1993)

    Google Scholar 

  5. Flach, P., Sokol, K., Wielemaker, J.: Simply logical - the first three decades. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 184–193. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_15

  6. Genesereth, M.: Dynamic logic programming. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 197–209. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_16

  7. Green, C.C.: Application of Theorem Proving to Problem Solving. In: Walker, D.E., Norton, L.M. (eds.) Proceedings IJCAI, pp. 219–240. William Kaufmann (1969)

    Google Scholar 

  8. Gupta, G., Salazar, E., Arias, J., Basu, K., Varanasi, S., Carro, M.: Prolog: past, present, and future. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 48–61. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_4

  9. Hermenegildo, M.: Parallelizing irregular and pointer-based computations automatically: perspectives from logic and constraint programming. Parallel Comput. 26(13–14), 1685–1708 (2000)

    Article  MATH  Google Scholar 

  10. Hermenegildo, M., Morales, J., Lopez-Garcia, P., Carro, M.: Types, modes and so much more - the prolog way. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 23–37. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_2

  11. Kowalski, R.A.: Predicate logic as a programming language. In: Proceedings IFIPS, pp. 569–574 (1974)

    Google Scholar 

  12. Kowalski, R., Kuehner, D.: Linear resolution with selection function. Artif. Intell. 2(3), 227–260 (1971)

    Article  MathSciNet  MATH  Google Scholar 

  13. Kowalski, R., Sadri, F., Calejo, M., Dávila-Quintero, J.: Combining prolog and imperative computing in LPS. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 210–223. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_17

  14. Kowalski, R.A.: The early years of logic programming. Commun. ACM 31(1), 38–43 (1988)

    Article  MathSciNet  Google Scholar 

  15. Leuschel, M.: ProB: harnessing the power of prolog to bring formal models and mathematics to life. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 239–247. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_19

  16. Morales, J., Abreu, S., Hermenegildo, M.: Teaching prolog with active logic documents. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 171–183. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_14

  17. Pereira, L., Pereira, F., Warren, D.: User’s Guide to DECsystem-10 Prolog. Dept. of Artificial Intelligence, Univ. of Edinburgh (1978)

    Google Scholar 

  18. Robinson, J.A.: A machine oriented logic based on the resolution principle. J. ACM 12(23), 23–41 (1965)

    Article  MathSciNet  MATH  Google Scholar 

  19. Tabakova-Komsalova, V., Stoyanov, S., Stoyanova-Doycheva, A., Doukovska, L.: Prolog education in selected high schools in Bulgaria. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 144–153. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_12

  20. Warren, D.S.: Introduction to prolog. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 3–19. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_1

  21. Warren, D.S.: Writing correct prolog programs. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 62–70. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_5

  22. Warren, D.S., Denecker, M.: A better logical semantics for prolog. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 82–92. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_7

  23. Warren, D.: Applied logic-its use and implementation as programming tool, Ph. D. thesis, University of Edinburgh (1977), also available as SRI Technical Note 290

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Manuel V. Hermenegildo .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Hermenegildo, M.V., Morales, J.F., Lopez-Garcia, P. (2023). Some Thoughts on How to Teach Prolog. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M.V., Kowalski, R., Rossi, F. (eds) Prolog: The Next 50 Years. Lecture Notes in Computer Science(), vol 13900. Springer, Cham. https://doi.org/10.1007/978-3-031-35254-6_9

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-35254-6_9

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-35253-9

  • Online ISBN: 978-3-031-35254-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics