The Power of Prolog



A Prolog Haiku:
        Unification—
        and backtracking predicates.
        Throughout the seasons.
      



Prolog is a programming language that is rooted in classical logic. It supports backtracking and unification as built-in features. Prolog allows us to elegantly solve many tasks with short and general programs.

Prolog has a pure monotonic core. The following documents are centered around this important aspect of Prolog, allowing declarative debugging and many other approaches that are impossible or only rudimentarily developed in other programming languages.

A Prolog program consists of predicates. Each Prolog predicate defines a relation between its arguments. A relation is a generalization of a function. Prolog predicates are often more versatile than functions in other programming languages, and are typically usable in multiple directions.

Prolog has several facets that distinguish it from many other programming languages. In addition, the language has undergone significant developments in the last few decades. The increasing availability of more declarative features allows us to present the language in a more uniform way that is easier to understand and at the same time yields more general programs with less effort than was the case with early Prolog versions.

  1. Basic Concepts
  2. Data Structures
  3. Global Variables
  4. Reading Prolog Programs
  5. Integer Arithmetic
  6. Higher-order Predicates
  7. Logical Purity
  8. Termination
  9. Writing Prolog Programs
  10. Declarative Testing
  11. Declarative Debugging
  12. Thinking in States
  13. Definite Clause Grammars (DCGs)
  14. Meta-interpreters
  15. Macros
  16. Combinatorial Optimization
  17. Expert Systems
  18. Web Applications
  19. Theorem Proving
  20. Efficiency
  21. Horror Stories
  22. The Future


Selected example programs are available as showcases.


About you


You are currently learning or teaching Prolog and find the existing literature somewhat unsatisfying. Is Prolog still the same language it was decades ago? Are the existing books still applicable? If not, what does modern Prolog code look like?

You can sense that Prolog is a powerful language, yet you are currently unable to use it to its fullest potential. In fact, it sometimes seems too limited to you to solve real problems. On the other hand, you know that Prolog is the most widely used logic programming language. How can this be?

Parts of the presented material seem new and unusual to you, and even contradict what others tell you about Prolog. In such cases, it is only natural to ask how legitimate the material is. Can you rely on what the author is saying?


About me

In 2005, I contributed library(simplex) to SWI-Prolog and worked on library(assoc). Together with a colleague, I won the online version of the Prolog Programming Contest in 2006 and 2007. Since 2007, I am contributing the CLP(FD) solver that ships with SWI-Prolog. Also since 2007, I have been maintaining the comp.lang.prolog Frequently Asked Questions.

In 2008, I received a Master's degree from the Vienna University of Technology after solving a combinatorial optimization task called the Social Golfer Problem.

In 2014, I received a doctoral degree from the Vienna University of Technology in the area of Prolog and constraints. You can read my thesis. Also since 2014, my CLP(B) solver ships with SWI-Prolog.

Since 2016, I have moved development of my constraint libraries to SICStus Prolog. See CLP(Z) for more information.

I am author and co-author of several scientific publications about combinatorial optimization, Prolog and constraints. I am mentioned as one of the contributors to the Prolog teaching environment GUPU and have contributed to the Prolog ISO standard (N226).

I learned almost everything I know about Prolog from Ulrich Neumerkel, Stefan Kral, Richard O'Keefe, Bart Demoen, Tom Schrijvers, Leon Sterling, Ehud Shapiro, Jan Wielemaker and Mats Carlsson.

What does this all mean? All considered, you still have to draw your own conclusions. Good luck!


Recursion

Main page