Prolog Introduction for Hackers
kuro5hin.org
kuro5hin.org
Sterling and Shapiro's _The Art of Prolog_ is wonderful, on par with (say) SICP. It focuses as much on the logic programming model as Prolog proper.
I am curious to explore how the Erlang interpreter was written, in light not of the similarities, but the subtle differences between the two languages. The use of -> was particularly interesting in comparison to how it is used in Erlang.
In Prolog (as with Haskell, OCaml, and others), you can define new operators with user-definable meaning and precendence. ->, !, and some other operators used in Erlang were left undefined in Prolog specifically for making DSLs. (That's also why Erlang code looks approximately like Prolog code with a bunch of extra operators added - it was a Prolog DSL.)
Prolog is a pretty good language for quickly protyping interpreters.
Implementing an efficient Prolog involves implementing the Warren Abstract Machine (WAM) [0]. I just implemented a very small and restricted subset of the WAM with a friend for a class final, and doing that is much harder. (Largely because there's not a whole lot in the way of documentation, and even the book that's supposed to serve as a WAM tutorial [1] is light/vague on some of the trickier implementation details.)
[0] http://en.wikipedia.org/wiki/Warren_Abstract_Machine [1] http://wambook.sourceforge.net/
Another major direction for practical Prolog implementation is constraint programming. I've been studying that off-and-on for a while, and Daniel Diaz's papers on clp(FD) (http://cri-dist.univ-paris1.fr/diaz/publications/) and adding CLP to the WAM seem to be a good intro.
The high water marks for efficient Prolog implementations are Peter Van Roy's work on Aquarius and The Mercury Programming Language.
Also, PVR's _CTM_ (http://www.info.ucl.ac.be/~pvr/book.html) has a really good one-chapter overview of Prolog, among many other things.
PS: swannodette, did you get the pattern matching and binary decision diagram stuff I sent you?
Thanks for the papers!
Better example of working with partial information: Constraint programming.
For an even more dramatically simplified version, I wrote a extremely toy interpreter in about a hundred lines of SML: http://everything2.com/title/continuation+passing+style
Or of course, you can implement it in a single line of Prolog. :)
Many Lisp books implement Prolog. Try PAIP and/or On Lisp. PAIP puts more time into implementing it well, but On Lisp covers the main ideas. I recommend both, regardless.
Very educational, if not so practical.
In Java.
The professor has taken down the course website, or I'd point you right to the assignment.
Really, my sibling commenters have described it well: it's probably between 200-600 LOC, getting a simple implementation is easy but getting a performant one is hard, etc.
It seems it didn't really meet that promise -- 'analog' approaches such as SVMs, Bayesian networks have turned out to be much better than logical reasoning for most real world AI approaches.
Why use Prolog (except for curiosity)? Is it easier to make some kinds of programs in it? (which are useful in the real world, not backtracking AI for simple games)