4 ms·
Funny. Chapter 24 of Paul Graham's On Lisp is about implementing Prolog in Common Lisp.
by ealhad 8y ago
Funny. Chapter 24 of Paul Graham's On Lisp is about implementing Prolog in Common Lisp.
- zerr 8y agoIt's obligatory for any Lisp book to include a Prolog implementation.
- vram22 8y agoInteresting. Do you know why?
- lispm 8y agoImplementing some kind of Prolog (and also other logic formalism) was common in the AI boom. Some were primitive (for example only using Lisp-like syntax), some were quite extensive (then also providing Edinburgh-Prolog syntax). Most AI tools included some reasoning facility, often in the form of some Prolog. The two commercial Common Lisps (Allegro CL and LispWorks) still offer Prolog implementations. One of the more extensive treatments of implementing Prolog-like features can be found in "Paradigms of Artificial Intelligence Programming" (PAIP) by Peter Norvig. Book and code available here: https://github.com/norvig/paip-lisp https://github.com/norvig/paip-lisp
- ken 8y ago"Prolog is similar to Lisp on the main points." (ibid)
- triska 8y agoIn my opinion, this is true for some main points, but definitely not for all of them. A key difference between the languages is in how easily you can reason about programs. In Prolog, if you program in the pure monotonic subset of the language, you get certain algebraic guarantees that are not available in Lisp. For instance, for pure Prolog code and a declarative reading, removing a goal can at most increase the set of solutions, and removing a clause can at most decrease the set of solutions. In Prolog, these guarantees can be used to test and debug your programs by logical reasoning. In fact, to a significant extent, you can even automate debugging due to these properties. Such techniques were pionereed by Ehud Shapiro in his 1982 PhD thesis, Algorithmic Program Debugging: http://cpsc.yale.edu/sites/default/files/files/tr237.pdf http://cpsc.yale.edu/sites/default/files/files/tr237.pdf The thesis is an excellent read, and I highly recommend it! Specifically, quoting from page 155: “Although Lisp is considered a high level language, it is not clear that it encourages precision and clarity of thought. As one Lisp hacker puts it [91]: "Lisp...is like a ball of mud. You can add any amount of mud to it...and it still looks like a ball of mud!". This aspect of Lisp is the hacker's delight, but the theoretician's nightmare. It is known that one may implement without too much effort a reasonable Prolog in Lisp. However, the issue is not implementation — the issue is the method of thought. Based on my experience with both languages I maintain that one's thoughts are better organized, and one's solutions are clearer and more concise, if one thinks in Prolog rather than in Lisp.” Another key feature of Prolog is that constraints blend in seamlessly, leading to an important declarative programming paradigm called constraint logic programming (CLP). This is the key reason why Prolog is frequently used to solve combinatorial tasks in practice, and often an important motivation for buying a commercial Prolog system.
- lispm 8y ago> Although Lisp is considered a high level language Lisp is generally not restricted to a particular 'level'. It also comes out-of the box with support for different programming paradigms - but no particular language support for logic programming. > if one thinks in Prolog rather than in Lisp Lisp supports high-level programming in logic by zillions of extensions. This has been popular throughout Lisp's history. Thus if we have a problem which is best solved by some kind of Logic, then it would be great of the Lisp system could be programmed in terms of that logic - which is not unusual. That said, a programming language built from the ground on some logic formalism like Prolog is a great tool.
- vram22 8y agoInteresting, thanks. Will check out that book, had heard about it.