SWI-Prolog Wiki entry
There is a wiki entry at the SWI-Prolog Discourse Group with a lot of links.
A paper describing SWI-Prolog in general: An Overview of the SWI-Prolog Programming Environment (January 2003)
Learn Prolog Now by Patrick Blackburn, Johan Bos, and Kristina Striegnitz. Available in book form since 2006, too.
In English and French (" Prolog tout de suite " ... but everybody in the office wanted Java)
- Learn Prolog Now
- Special version for SWI-Prolog which integrates with SWISH, also in the "Tutorials" menu at the top of this page.
From the book "Language Processing with Perl and Prolog"
The Power of Prolog on YouTube is a series of excellent presentations by Markus Triska
The Stanford Encyclopedia of Philosophy is hard to beat:
If you are good at theory (Mind Blown!)
SWISH: Online SWI-Prolog
Want to code now?
Use SWISH (SWI-Prolog for Sharing) for experimentation. It's (subset of) SWI-Prolog on a server, accessed via your browser.
- You can create programs and run queries against them.
- You can create "notebooks" of code and query
Be sure to read the Help and Examples menus.
It's dangerous to go alone! Take this:
Unit testing is less about testing than about proper and manageable coding - it's like having a lab notebook. Don't even try to do without. Especially not in Prolog, which has no guardrails at all. You will be surprised at what your tests tell you.
Prolog visualizer created by Zhixuan Lai and Alessandro Warth at CDG labs LA; shows what's going on more clearly than a debugger.
Coding guidelines, style tips
- Coding Guidelines for Prolog (PDF) by Michael Covington et al. (this should be in an open HTML document, not buried in a PDF).
- Prolog Coding Horror(s)
You also should get into writing good comments. There is markup for this:
This comment section also uses PlDoc markup.
Some basic lingo
- SWI-Prolog's own glossary
- This question on StackOverflow: Is this Prolog terminology correct? (fact, rule, procedure, predicate, …)
- "The Prolog Dictionary" by Bill Wilson
- My certainly less-than perfect writeup of the "Byrd Box Model"
- The "Prolog" tag at StackOverflow - but please search for answer to your potential question first. Interesting and well-formulated questions only pop up rarely though.
- The SWI-Prolog group at Discourse
Pages listing resources
In this manual
- SWI-Prolog manual's list of materials
- SWI-Prolog manual's list of publications
- There is the bibliography, but it's not so helpful
- More info than one can handle at Robert Kowalski's Homepage
- The aformentioned Prolog tag at StackOverflow
- Metalevel.at Prolog FAQ here and here
- A page at GitHub
- The tail end of Wikipedia page for Prolog
- Also this: Comparison of Prolog Implementations
Definite Clause Grammars (DCGs)
Markus Triska writes in his DCG tutorial:
Consider using DCGs if you are: - describing a list - reading from a file - passing around a state representation that only a few predicates actually use or modify. In every serious Prolog program, you will find many opportunities to use DCGs due to some subset of the above reasons.
In this manual:
Introduction and tutorials:
Also take a look at:
The usage of "difference list" is not entirely clear:
This is about working at the end of a list terminating not in  but in an unbound variable (aka. "an open list") for efficient append operations...
Or it is about "a list described by a pair of lists", where all the lists are proper (not-open) lists, in particular in the context of DCGs:
- The application of Difference Lists to DCGs by Markus Triska. There are called (appropriately) "list differences"
In the literature, you will also encounter the term "difference list". However, this terminology is misleading: We are not talking about — as the name may suggest — a special kind of list. The additional arguments are completely ordinary lists. It is their differences that matter especially in such cases.
One will have to live with this ambiguity.
- My own explainer: About difference lists
Constraint Logic Programming (CLP)
Start at the manual page for CLP.
Quickly get used to using numeric constraints to express relationships between integers, instead of performing function evaluation on the right with
is : manual page for CLP(FD)
Constraint Handling Rules (CHRs)
This is a formalism for writing forward-chaining rewrite rules on top of Prolog. One should at least be aware that these exist so that one can use them when appropriate.
Prolog is for programming (search-augmented programming) using a certain formalism from logic, rather than for theorem proving. One can build a theorem prover on top of it, however, for theorem proving, look at things like:
Here is a paper on a simple FOL prover in Prolog
History of Prolog
- Prolog Héritage: The Prologs from Marseille
- Robert Kowalski's 2014 paper History of Logic Programming. I would say it's actually the "Prehistory" because modern approaches have not yet made it into the paper.
- Alain Colmerauer and Philippe Roussel: The birth of Prolog (November 1992).
- Peter Van Roy's 1993 overview 1983--1993: The Wonder Years of Sequential Prolog Implementation ... This report surveys the major developments in sequential Prolog implementation during the period 1983--1993. In this decade, implementation technology has matured to such a degree that Prolog has left the university and become useful in industry.
- Robert Kowalski's 1988 paper The Early Years of Logic Programming, which appeared in a "Communications of the ACM" special issue (January '88: https://cacm.acm.org/magazines/1988/1 )
- If you are writing a paper for, say, the IEEE Annals of the History of Computing, there is a lot of further pointers here: http://www.softwarepreservation.org/projects/prolog/
Books on Thinking, Logic & Computation
On the SWI-Prolog bibliography page a commenter mentions this book:
Thinking as Computation: A First Course by Hector J. Levesque, 2012
Simply Logical: Intelligent Reasoning by Example by Peter Flach, 1994
Computational Logic and Human Thinking - How to Be Artificially Intelligent by Robert Kowalski, 2011
Natural Language Processing
Specifically for Natural Language Processing, there are tons of resources.
Although, just by looking at manning.com, what's done today for actual NLP is done in Python wrapping Tensorflow libraries to hoover Twitter feeds for sentiment analysis to predict political trends.
Start with an overview at the Stanford Encyclopedia of Philosophy: Computational Linguistics
In a recent (heavy) textbook:
Introduction to Natural Language Processing
by Jacob Eisenstein, 2019
the author goes far beyond "NLP and Parsing" (indeed the part on Formal Language Theory, Context-Free Parsing, Dependency Parsing is only 80 pages of 450) and throws statistics and neural networks at the problem.
Prolog related works by reverse year of publication:
An Introduction to Language Processing with Perl and Prolog by Pierre M. Nugues, 2nd edition, 2014
*"An Outline of Theories, Implementation, and Application with Special Consideration of English, French, and German"*
Contains an intro to Prolog, specifically SWI-Prolog.
Natural Language Processing Techniques in Prolog by Patrick Blackburn and Kristina Striegnitz, 2002
Prolog and Natural-Language Analysis by Fernando C. N. Pereira and Stuart M. Shieber, (Original 1987, Millenial reissue 2002)
I liked the view on basic logic programming from the LISP side. This is the basis of Kanren and miniKanren:
- The Reasoned Schemer by Daniel P. Friedman, William E. Byrd and Oleg Kiselyov, 2005-10
- Reference at MIT Press
A thin book (but pricey).
(The blurb saying "Friedman and Kiselyov extend Scheme to form a completely new kind of logic programming system, one which is in many ways even more elegant than Prolog." I don't know about that.)
A fascinating page on a fascinating site, by Oleg Kiselyov (must have reached at least Spock level):
Last but not least
A recent overview textbook by ACM Books:
- Declarative Logic Programming: Theory, Systems, and Applications Editors: Michael Kifer & Yanhongannie Liu, 2018-09
- Reference & chapter list at ACM