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)
An Introduction to Prolog from the book Language Processing with Perl and Prolog
Markus Triska has now a bunch of excellent presentations on YouTube under The Power of Prolog:
- To kick off, "Logical Foundations of Prolog":
The Stanford Encyclopedia of Philosophy is hard to beat:
- The entry on Classical Logic: https://plato.stanford.edu/entries/logic-classical/
- The entry on Automated Reasoning: https://plato.stanford.edu/entries/reasoning-automated/
- ...and thereunder on Logic Programming: https://plato.stanford.edu/entries/reasoning-automated/#LogPro
- The entry on Logic and AI: https://plato.stanford.edu/entries/logic-ai/
If you are good at theory (Mind Blown!)
- Frank Pfenning's Course on Logic Programming: http://www.cs.cmu.edu/~fp/courses/lp/
SWISH: Online SWI-Prolog
Want to code now?
Use SWISH for experimentation. It's SWI-Prolog in your Browser:
Prolog visualizer created by Zhixuan Lai and Alessandro Warth at CDG labs LA; shows what's going on more clearly than a debugger.
Some basic lingo
- SWI-Prolog's own glossary: https://www.swi-prolog.org/pldoc/man?section=glossary
- This question on StackOverflow: https://stackoverflow.com/questions/49898738/is-this-prolog-terminology-correct-fact-rule-procedure-predicate
- "The Prolog Dictionary" by Bill Wilson: http://www.cse.unsw.edu.au/~billw/prologdict.html
- My certainly less-than perfect writeup of the "Byrd Box Model"
- The "Prolog" tag at StackOverflow: https://stackoverflow.com/tags/prolog/info - but please search for answer to your potential question first. Interesting and well-formulated questions only pop up rarely.
- The SWI-Prolog group at Discourse: https://swi-prolog.discourse.group/
Pages listing resources
In this manual
- SWI-Prolog manual's list of materials: https://www.swi-prolog.org/Links.txt
- SWI-Prolog manual's list of publications: https://www.swi-prolog.org/Publications.html
- There is the bibliography, but it's not so helpful: https://www.swi-prolog.org/pldoc/man?section=bibliography
- The aformentioned Prolog tag at StackOverflow: https://stackoverflow.com/tags/prolog/info
- Prolog FAQ: https://www.metalevel.at/prolog/faq/faq.html and https://www.metalevel.at/prolog/faq/
- A page at GitHub: https://github.com/klaussinani/awesome-prolog#resources
- The tail end of Wikipedia page for Prolog : https://en.wikipedia.org/wiki/Prolog
- Also this: https://en.wikipedia.org/wiki/Comparison_of_Prolog_implementations
- The "Prolog" category at Rosettacode : http://rosettacode.org/wiki/Category:Prolog
- 99 Prolog Problems : https://www.ic.unicamp.br/~meidanis/courses/mc336/2009s2/prolog/problemas/ (the Swiss page at BFH.ch is down)
You need guidelines:
- Coding Guidelines for Prolog by Michael Covington et al. https://arxiv.org/abs/0911.2899 (can also found at other sites) (this should be an HTML document, not buried in a PDF).
You need style:
You also should get into writing good comments. There is markup for this:
- "PIDoc: Wiki style Literate Programming for Prolog": https://www.swi-prolog.org/download/publications/pldoc.pdf
No code without unit tests. Here is the testing framework and some info:
Definite Clause Grammars (DCGs)
In this manual:
Introduction and tutorials:
- https://www.metalevel.at/prolog/dcg by Markus Triska
- http://www.pathwayslms.com/swipltuts/dcg by Anne Ogborn
- https://en.wikipedia.org/wiki/Definite_clause_grammar (has more references)
Also take a look at
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.
This is about working at the end of lists and creating efficient append operations.
- "Difference List" wiki entry at SWI-Prolog discourse site: https://swi-prolog.discourse.group/t/difference-list/959
- Frank Pfenning - "Difference Lists": https://www.cs.cmu.edu/~fp/courses/lp/lectures/11-diff.pdf
- The application of "Difference Lists" to DCGs by Markus Triska: https://www.metalevel.at/prolog/dcg . They are called "list differences" here: _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._
- My own explainer: About difference lists
Constraint Logic Programming (CLP)
Quickly get used to using numeric constraints to express relationships between integers, instead of performing function evaluation on the right with
is : https://www.swi-prolog.org/pldoc/man?section=clpfd
Constraint Handling Rules
This is a formalism for writing forward-chaining rewrite rules on top of Prolog:
One should at least be aware that these exist.
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 FOL prover in Prolog:
History of Prolog
- Prolog Héritage: The Prologs from Marseille http://prolog-heritage.org/
- Robert Kowalski's 2014 paper History of Logic Programming (I would say it's the, "The Prehistory" because modern approaches have not yet made it into the paper), 2014: https://www.researchgate.net/publication/277670164_History_of_Logic_Programming
- Alain Colmerauer and Philippe Roussel: The birth of Prolog (November 1992): http://alain.colmerauer.free.fr/alcol/ArchivesPublications/PrologHistory/19november92.pdf
- Peter Van Roy's 1993 overview 1983--1993: The Wonder Years of Sequential Prolog Implementation: https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.29.9583 ... 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 ), paper available for example here: https://www.doc.ic.ac.uk/~rak/papers/the%20early%20years.pdf
- 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/
Thinking, Logic & Computation
On the SWI-Prolog bibliography page (https://eu.swi-prolog.org/pldoc/man?section=bibliography) a commenter mentions:
Thinking as Computation
by Hector J. Levesque, 2012
Simply Logical: Intelligent Reasoning by Example
by Peter Flach, 1994
Download available at the author's website:
Computational Logic and Human Thinking - How to Be Artificially Intelligent
by Robert Kowalski, 2011
Download available at the author's website:
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 (as opposed to command language processors) is done in Python pulling in Tensorflow libraries to analyze Twitter feeds.
Start with an overview:
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
A thin book (but pricey ... and you will not be able to resist annotating it).
(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 feel that happens, at least not in this book.)
A fascinating page on a fascinating site, by Oleg Kiselyov (you must have reached at least Spock level)
More info than one can handle at Robert Kowalski's Homepage:
A recent overview textbook by ACM Books:
Declarative Logic Programming: Theory, Systems, and Applications
Editors: Michael Kifer & Yanhongannie Liu, 2018-09