SWI-Prolog Wiki entry
There is a wiki entry at the SWI-Prolog Discourse Group with a lot of links.
Gentle introduction
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: Channel
- To kick off, "Logical Foundations of Prolog":
The Stanford Encyclopedia of Philosophy is hard to beat:
- Classical Logic
- Automated Reasoning
- ...and thereunder Logic Programming
- The entry on Logic and AI
Robert Kowalski has the the content of the first edition of Logic for Problem Solving (1979) at this page as well as commentary to the revised edition of 2014.
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
Available online:
Computational Logic and Human Thinking - How to Be Artificially Intelligent by Robert Kowalski, 2011
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.
Unit testing
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
Prolog visualizer created by Zhixuan Lai and Alessandro Warth at CDG labs LA; shows what's going on more clearly than a debugger.
- http://www.cdglabs.org/prolog/#/ (See its (i) menu)
- Presentation at Slideshare
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"
Discussion Groups
- 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
- SWI-Prolog manual's Glossary which could use some extension
Others
- More info than one can handle at Robert Kowalski's Homepage
- Frank Pfenning's Course on Logic Programming if you are good at theory. (Btw Frank Pfenning edited the collection Types in Logic Programming back in '92. We still don't have (static/strong) types in logic programming .. except in Mercury)
- Course Notes for Markes Sergot's "Knowledge Representation" Course
My own link collection, including links to papers on the History of Prolog
Others
- 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
Code examples
- The "Prolog" category at Rosettacode
- 99 Prolog Problems (the Swiss page at BFH.ch is down)
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:
- By Markus Triska
- By Anne Ogborn
- Wikipedia on DCGs (has further references)
Also take a look at:
"Difference lists"
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...
- Difference list wiki entry at SWI-Prolog discourse site.
- Frank Pfenning on Difference Lists (PDF)
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 (which now needs review)
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.
Theorem proving
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
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)
Furthermore
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