Prolog Notes
Some notes taken while working on Prolog (mostly SWI-Prolog)
A Tradition
From The Fifty-three Stations of the Tōkaidō by Utagawa Hiroshige, 1832.
The Logic Programming Landscape
So many modeling languages which are also programming languages, all a bit different.
Missed in the above:
- αProlog (Currently frozen?)
- GOLOG (Ancient, based on Situation Calculus. What's the relationship to LPS?)
- MProlog (PDF) for Modal Logic
- NProlog: An extension of prolog with hypothetical implication.
- HYPROLOG A Logic Programming Language with Abduction and Assumptions
- GOAL Agent Programming Language
- LogicBlox
- Datalog
- Logical Frameworks
- Markov Logic Networks -- This seems to be hot right now
- Lambda-Prolog: A pragmatic reconstruction of Lambda-Prolog
- There should be something here on implementation of more general theorem provers using the very restricted top-down theorem prover (or rather, "enumerating consequence checker") of Prolog. And how do you direct search in a theorem prover anyway? The NP desert is not for the faint of heart.
What is Prolog? In a 2012 paper by Peter Van Roy, Programming Paradigms for Dummies: What Every Programmer Should Know, the following diagram can be found on page 13:
Journals
Lest I forget:
- Theory and Practice of Logic Programming (Cambridge UP)
- The Journal of Logic Programming (Elsevier)
Notes
- Example code for some standard problems
- Prolog implementations for Fibonacci Number computation (code is tilted towards SWI Prolog though)
- A discussion of a "Prolog Database" operation
- Various code snippets (testing predicates found in the SWI-Prolog manual)
- Having to do with programming constructs, some of which are specific to Prolog or to SWI-Prolog
foldl
andfoldr
in Prologfindall/3
- Attributed Variables (an addendum to the SWI-Prolog manual page with new code)
- Delimited continuations (to be continued!)
- CHR: Constraint Handling Rules (there is nothing here yet)
- DCGs: Definite Clause Grammars (just some work in progress)
- Explaining
dif/2
(but it's actually very simple in the end) - Exceptions (exceptions are useful, but the ISO standard exceptions are open to improvement)
- The
maplist/N
predicates - Predicates dealing with I/O and printing (it all started with this...)
- Predicates for analyzing/constructing terms
- The use of the caret
^
inbagof/3
,setof/3
- SWI-Prolog string modes
- How to load a library (the lynx library in this case)
- Having to do with generally explaining Prolog
- "Byrd Box Model"
- Depicting Terms (needs review)
- Prolog list processing idioms
- The concept of a "Prolog variable" (needs review once more)
- Difference Lists (another one that is actually very simple in the end)
- Prolog data types (somewhat specific to SWI Prolog)
- Code to tag a Prolog term according to the data type decision tree:
tagging.pl
- Code to tag a Prolog term according to the data type decision tree:
- Having to do with JPL, the Java-Prolog Bridge
- Having to do with general questions
- Some notes on the Logic (Prolog is said to be based on classical logic, but is this really true?)
- Some notes on the Truth Values (Prolog is said to be based on two-valued logic, but is this really true, or advised?)
- Map of the Logic Programming landscape (actually quite detailed; shown above)
- Map of the Rule-based Systems landscape (first try)
- Freestyle Notes, undigested
Code grabbag
Some predicates which may be of general use can be found in the Code grabbag
External Resources
- The first page of the SWI-Prolog manual has a large comment with pointers to resources ... sometimes I add something to that comment.
- Extensive list at klaussinani's github account
- The Prolog Syntax Highlighting file for KDE (by Torsten Eichstädt), as used in the Kate editor
- Bug Hunting Toolbox Wiki Page at SWI-Prolog Discourse Site
- Frank Pfenning's Course on Logic Programming (Lecture Notes as one PDF ... 324 pages). Hardcore!
- Richard O'Keefe: An Elementary Prolog Library: Discussion about extending the ISO standard with a usable library.
- The Prolog dictionary by Bill Wilson
- The SWI-Prolog glossary aka. "Appendix D"
- Glossary of Logic Terms (PDF) by Marc Cohen
On YouTube: "The Power of Prolog" by Markus Triska
List of Markus Triska's "Power of Prolog" YouTube videos
Papers of Interest
Papers of interest (a small selection)
Packages of Interest
- https://github.com/shonfeder/tokenize - "A modest tokenization library for SWI-Prolog, seeking a balance between simplicity and flexibility."