[Haskell-cafe] Learn Prolog...

jerzy.karczmarczuk at info.unicaen.fr jerzy.karczmarczuk at info.unicaen.fr
Sat Sep 1 16:55:06 EDT 2007

Yes, I know, this is Haskell list. So, I apologize, but not too much... 

Johan Grönqvist cites me: 

>> Anyway, I believe strongly that ALL people who have problems...
>> should be encouraged to learn Prolog. IN DEPTH,
> Do you have a recommendation on how to do this?
> (e.g., books, web-pages, (available) lecture notes, problem sets)

First, install a decent Prolog on your machine. There are plenty: 


You may wish to install the free version of Visual Prolog. 

My favourite is the SWI Prolog:
(University of Amsterdam) 

The documentation is complete, and the reference manual contains references
to such standard books as ClocksinMellish, or Sterling&Shapiro. The last one
is very, very instructive. 

Also, Prolog Programming for Artificial Intelligence, written by Bratko, is
very useful. There are on the web collection of examples from this book,
don't remember where.
Try here:

On-line there are thousands of examples, tutorials, etc. 

J. Fisher: (There is an example of cut, especially for A. Coppin)



Etc., etc. Really!
Examples. For example: 


and of course there are discussion lists, FAQs, etc. Ask Google... 

Andrew Coppin writes: 

> I did once try to learn Prolog. And failed. Miserably.

> I just couldn't bend my head around how the Prolog interpreter manages to > make seemingly "impossible" leaps of deduction. (It's a *machine*! How can > it deduce arbitrarily complex conclusions from any arbitrary set of 
> axioms? That requires *intelligence*!) And yet, in other, seemingly 
> identical cases, it utterly fails to deduce patently *obvious* results... 
> really weird! 

One of standard exercices in Prolog is the construction of the
meta-interpreter of Prolog in Prolog. While this is cheating, I recommend
it to you. It opens eyes. 

Actually, there are three basic items to learn while trying to master Prolog
after having dealt with the syntactic essentials term construction, and the
1. The unification, which shows the "ultimate" instance of pattern-matching
  and is useful for recognizing some techniques for the automatic inference
  of types in functional languages. 

2. The usage of unbound "logical variable", which sometimes permits to
  to do things which require laziness in Haskell. 

3. The control backtracking, which is at the heart of the logical non-de-

Now, the non-deterministic algorithms in Haskell are usually implemented
using the *data backtracking*, or the List Monad. The control backtrack,
via, say success/failure continuations, is more difficult, they are rarely
taught, and problematic because of strong typing. 

Prolog strategies are straightforward, and I simply cannot understand the
comments of Andrew Coppin. Which arbitrary set of conclusions?? Which
patently obvious results not derivable?? Be kind, give some examples,
otherwise people may suspect that you are issuing vacuous statements... 

The best. 

Jerzy Karczmarczuk 

More information about the Haskell-Cafe mailing list