This page contains basic beginner and more advanced Prolog snippets; the purpose of this page is for those who are learning and like to learn (via pure code), as well as, a location for mpettersson to keep snippets and Prolog related links. This pages subsections are:


Prolog 101

The general and technical aspects of the  Prolog programming language are:

Uses: Application, AI
Get Started: Getting started quickly
Documents: SWI-Prolog documentation
Creator: Alain Colmerauer, Robert Kowalski
First Released: 1972
Implementation: Both Interpreted and Compiled
Type Safety:
Type System:
Type Checking: Dynamic
Imperative: No
Functional: Yes
Procedural: Yes
Reflective: Yes
Event Driven: No
Standardized: Yes
Failsafe I/O: Yes
Garbage Collected: Yes

For a “comprehensive free Prolog environment” download SWI-Prolog from the SWI Prolog download page. For just about everything you’d ever want to know about this particular version of Prolog, check out the SWI Prolog document page.

The following code snippet contains the instructions necessary to load a Prolog (.pl) file, furthermore, please note that the symbols ‘?-‘ simply represent (or indicate) the Prolog interpreter.

The contents of the Prolog file:


Miscellaneous Prolog Code

The following code is a collection of interesting Prolog code (well, at least from the perspective of an imperative programmer).

Binary Digits in Prolog


Prolog Resources

The following are links to Prolog related resources, such as books, blogs, tutorials, code, etc…
Logic, Programming and Prolog (2ed) by Ulf Nilsson and Jan Maluszynski
Prolog & Logic Programming Slides by Dr. Hamlen at UTD (my favorite professor at UTD).
Prolog Tutorial by J. R. Fisher


As always, please contact us with comments, concerns, questions, etc. about Prolog!