prolog_notes icon indicating copy to clipboard operation
prolog_notes copied to clipboard

Some notes taken while working on Prolog

Prolog Notes

Some notes taken while working on Prolog (mostly SWI-Prolog)

A Tradition

Hiroshige: Shinagawa Station

From The Fifty-three Stations of the Tōkaidō by Utagawa Hiroshige, 1832.

The Logic Programming Landscape

The Logic Programming Landscape

So many modeling languages which are also programming languages, all a bit different.

Missed in the above:

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:

Taxonomy of programming Paradigms (by Peter van Roy)

Journals

Lest I forget:

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 and foldr in Prolog
    • findall/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)
      • Catch with backtrace
      • Throwing ISO standard exceptions
      • Problems with the ISO standard exception terms
      • Throwing in style: collecting exception specs in one place of the code
      • Example code to verify predicate arguments
      • And also: Conditions à la Lisp as alternative/complement to exceptions
    • 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 ^ in bagof/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
  • Having to do with JPL, the Java-Prolog Bridge
    • Some test code
  • 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
    • About Predicate Structure
    • Salvaging a term out of a dropped search branch
    • Better type tests

Code grabbag

Some predicates which may be of general use can be found in the Code grabbag

External Resources

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."