Programación Lógica /
Logic Programming (2021-2022)


Welcome to the home page of "Programación Lógica / Logic Programming," a one-semester course on logic and constraint logic programming, covering basic concepts and programming practice.

This course is a mandatory subject in third year of the current 4 year Bachelor in Computer Science and Mathematics program and an elective in the Master's in Artificial Intelligence taught at the School of Computer Science, Technical University of Madrid (Department of Artificial Intelligence).

Please note that these pages are all under permanent construction/change. Suggestions, comments, questions, raves, rants, etc. should be directed by email to <>.

Note for UPM students: Basic course info, bibliography, grading, mailing lists, etc. can be found in the UPM Moodle site for the course.

Course Slides (in English) (note that these notes may be improved during the course):
  • (21-22) Introduction and Motivation. [pdf, code]
  • (21-22) A "hands-on" Introduction to Logic Programming. [pdf, code]
  • (21-22) Using the Logic Programming system (environment, top level, debugger, etc.). [pdf]
  • (21-22) The Prolog Programming Language. [pdf, code]
  • (21-22) Constraint Logic Programming. [pdf, code, code for finite domains.]
  • Additional material:
  • Some background theory:
  • Slides covering many other related topics.
  • Acknowledgments.
    Programming system used in the course: Recommended textbook:
    GNU Emacs Reference Card
    Using this material: You are welcome to use all or part of this course material, but if you do so we ask you to please quote the origin. We would also very much appreciate if you let us know that you are using it and send us any errors you may find by email to <>. Thanks in advance.

    General note: We used to start with basic theory (resolution, etc..), then Logic Programming, then Prolog. Soon, we decided to start directly with a quick introduction to Logic Programming and jump as soon as possible to actual programming (both traditional Prolog and more recent LP and CLP languages), and to relate things at the end back to logic theory. This is the version in these pages -- which is not very different from the previous one, except for the order. If you prefer to start with theory, just use the theory slides first and remove some slides (first order languages and unification, mainly) from the introduction to logic programming. (One of the reasons for doing things this way is that our students take two semesters of logic prior to this course and are therefore quite familiar with, e.g., resolution, models. etc., but not with logic programming.)