5 ms·
If you want to know how to build a Prolog . . . When I learned Common Lisp, I devoured the available textbooks in 1989 and for a few years after. A book from
by DannyB2 7y ago
If you want to know how to build a Prolog . . .
When I learned Common Lisp, I devoured the available textbooks in 1989 and for a few years after. A book from the early 1990s is: Paradigms of AI Programming: Case Studies in Common Lisp. By Peter Norvig (now employed by Google)
The book first teaches you Common Lisp, which isn't that difficult to pick up. But that itself is a transformative experience.
Then the book shows you how to build a number of amazing things using Common Lisp. It starts IIRC, with pattern matching. Term rewriting. Unification matching.
Then you proceed to build a few things like:
1. A program that solves high school style algebra word problems.
2. A "prolog" (but expressed in Lisp syntax) that is a "hair's breadth" (in the author's words) from real prolog.
This book was mind blowing. A revelation. Insightful.
Learning Lisp (even from other textbooks before the one I mention here) was a transformative experience. But this single book stands out in providing so many amazing ideas expressed in Lisp.
Other Lisp texts I had read taught me things like playing two-player zero sum games (TicTacToe, Checkers, Reversi). I abstracted the technique to have a single re-usable AI engine implementing the Minimax with Alpha-Beta pruning, and then different layers on top of that which implemented different games (as listed earlier) by defining a game board, move generator and board scoring function.
One Lisp textbook I had from the late 1980s showed a program to plan movements of a robot arm to manipulate blocks according to english like commands.
All of these amazingly sophisticated things take up very little Lisp code. Often only a few pages.
The journey of learning Lisp, with a really good textbook, is an amazing learning experience. Learning Lisp will change the way you think about code for the rest of your entire life. I can confidently say that having learned Lisp starting in about 1986 and dabbling with it through 1993. The initial learning comes quickly. But you will play with this new toy for a long time.
Another book (The Elements of Artificial Intelligence Using Common Lisp) introduced me to the A-star search. I've used that technique, in Java, to build a "solver" for a game sometimes called "Traffic Jam" or "Unblock Me".
- tsuru 7y agoThe first book, commonly referred to by its acronym PAIP, is available online for free from the author: https://github.com/norvig/paip-lisp https://github.com/norvig/paip-lisp I think there is ongoing effort to update it for better accessibility.
- DannyB2 7y agoI would love to see it updated for Clojure and/or Racket.
- dhconnelly 7y agoHere it is in Python, if that's interesting: https://github.com/dhconnelly/paip-python https://github.com/dhconnelly/paip-python (Also responded directly to your comment above, but just in case this is helpful here as well :)
- dhconnelly 7y agoWhat a great book! I translated most of the Lisp code into Python a while back. You can find it on Github: https://github.com/dhconnelly/paip-python https://github.com/dhconnelly/paip-python The logic programming bits in particular (the core of the Prolog interpreter) can be read in a maybe-nicer way here: http://dhconnelly.com/paip-python/docs/paip/logic.html http://dhconnelly.com/paip-python/docs/paip/logic.html
- deleted 7y ago[deleted]
- dreamcompiler 7y agoPG's book "On Lisp" also implements an interesting Prolog compiler in Common Lisp. His uses continuation-passing macros.