Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
The Birth of Prolog (1992) [pdf] (stanford.edu)
133 points by mindcrime on Oct 9, 2018 | hide | past | favorite | 39 comments


I found Ivan Bratko's Prolog Programming for Artificial Intelligence excellent (I've read the previous two editions, but not the current 4th).


I enjoyed it. I didn't read other prolog books since so I can't compare but I'd still suggest it.


I've noticed prolog being mentioned here and a bunch of other places, but haven't really found any good introductory books on the language.

Does anyone have any recommendations?


AI Algorithms, Data Structures, and Idioms in Prolog, Lisp, and Java, by George Luger, free from the author's personal page on Florida State uni, here:

https://www.cs.fsu.edu/~cap5605/Luger_0136070477_1.pdf

This is an excellent resource also for LISP (and Java!) and AI algorithms, particularly various search strategies.

I'd also recommend the standard Prolog textbtook, Prolog Programming for AI, by Ivan Bratko. You can most likely find an edition in most university libraries.

I've learned a lot from Adventure in Prolog, a Prolog tutorial on the Amzi! Prolog website (though I used a different Prolog to do the exercises, which is a very good sign of nice, basic and portable examples):

http://www.amzi.com/AdventureInProlog/advtop.php

Those are practical resources. On a more theoretical side, another commenter recommended Perreira & Shreiber, which I can't recommend enough. Also, for a more formal text on logic programming, with proofs and all, the classic reference is J. W. Lloyd, Foundations of Logic Programming. Again, you can probably find a copy in your friendly neighbourhood university library (or, er, google it for a very bad copy of dubious legitimacy, like).


The exposure most people have to prolog in school is about a chapter in the "programming languages" course.

Yes, pick any book and work through it from page 1 to the end. Preferable 3! Read and pour through the manuals for whatever interpreter & compiler you use. Be warned, Prolog will ruin you, you shall be able to slay dragons and at the same time you most likely will not enjoy programming in "modern languages" anymore.

(Intro/Novice)

  Learn Prolog Now (free on the web)
  Adventure in Prolog(free on the web)
  Logic Programming with Prolog
(Intermediate)

  The Practice of Prolog
  Prolog Programming for Artificial Intelligence
  Prolog Programming In Depth
  Prolog Experiments in Discrete Mathematics, Logic, and Computability
(Advanced)

  The Art of Prolog
  The Craft of Prolog
  Clause and Effect
  Simply Logical

  Prolog and Natural Language Analysis
  Meta Programming Logic
  Intelligent Image Processing in Prolog
  Expert Systems in Prolog
  Functional Grammar in Prolog
(Papers)

  Warren Abstract Machine
  Negation and Control in Prolog


For a really nice explanation of the Warren Abstract Machine, see "Warren's Abstract Machine: A Tutorial Reconstruction" by Hassan Aït-Kaci: http://wambook.sourceforge.net


Clocksin & Mellish has the benefit of being a slim volume, which makes it approachable.

Sterling & Shapiro (Art of Prolog) has much more depth. Not sure I'd recommend to a beginner. (It has a beautiful cover, though and is almost worth getting just for that.)

My favorite Prolog book is Pereira & Sheiber's "Prolog and Natural-Language Analysis". It's slanted toward NLP but the coverage of Prolog itself is top notch.

https://www.amazon.com/Natural-Language-Analysis-Information...


I thought I was probably the only person who read PNLA book, but it's absolutely fantastic!


Uh, the cover did not move me. Especially at $150


https://mitpress.mit.edu/books/art-prolog-second-edition

That's the book they meant (referred to as having a "beautiful cover").


...and it’s Open Access, i.e. free download.


Holy Cow, I had no idea. I have a physical copy, but now I can suggest this to everyone.


That was the best Prolog book I have read.


http://www.mtome.com/Publications/PNLA/prolog-digital.pdf

I just googled that and don't know if it's a legitimate source, but I've previously downloaded a copy from the site of one of the authors, so it's probably all right.


Buy it used, it's been the same edition for twenty or thirty years.


Learn Prolog Now! is a decent starting place.

http://www.learnprolognow.org/lpnpage.php?pageid=online


Peter Flach's "Simply Logical: Intelligent Reasoning by Example" also deserves to be mentioned as a wonderful introduction to Prolog and computational logic in general. It's available as a PDF from the author (http://people.cs.bris.ac.uk/~flach/SimplyLogical.html) and also in an interactive version where the examples can be run in-browser, using SWISH: https://book.simply-logical.space/


"The Power of Prolog" by Markus Triska is quite good. https://www.metalevel.at/prolog


I found this book not very useful as a beginner. I plan to revisit it when I get further in.


Clocksin/Mellish is kind of the traditional text. A bit boring conventional maybe.

Shapiro is probably the best.

Bratko is highly regarded.


Strong second for Art of Prolog (assuming that's the Shapiro text you're recommending?)


People have already recommended it, but "Programming in Prolog" by Clocksin and Mellish was the text book for the Prolog course that SWI-Prolog offered back in June.

I'd recommend the class if it were offered again.


Clause & Effect is shorter than the others mentioned so far, and very good.


Picat language was also mentioned recently and it has logic programming facilities.


I wish there was a way to electrify such paper scans into some roff or TeX format for perfect reproduction and scalability. Anyone up for an ML project doing that?


I emailed Dr Colmerauer about this once and asked about the Fortran source, but his recollection is that it has been lost. :-/


It's a fun language to play around with and everything. Just have never seen anyone us it at scale in the industry other than folks doing research/academia.


"Datalog is a declarative logic programming language that syntactically is a subset of Prolog." [1]

"Datomic is a distributed database and implementation of Datalog.". Datomic seems to be quite succesful [2].

Related to datomic, I'm trying to learn Datascript these days ("An immutable in-memory database and Datalog query engine in Clojure and ClojureScript.") [3].

1: https://en.wikipedia.org/wiki/Datalog

2: https://www.datomic.com/customers.html

3: https://github.com/tonsky/datascript


Datalog is a subset of Prolog syntax and logical semantics, but not of its operational semantics, so in practice the link is tenuous.

I like the honest words of Serge Abiteboul (co-author of Foundations of Databases http://webdam.inria.fr/Alice/) on this topic:

This is back to the advantages of “declarative programming”. The first scam was Prolog: The language is not really declarative. The second scam was Datalog: It is declarative, but there is not much you can do with it.

Datalog is simple and beautiful – Horn clauses. We theory guys had a ball with it. There were beautiful results to obtain even at the cost of further simplifications (e.g., monadic to be able to decide containment). But the scam is that if you want to do anything serious beyond your stupid positive first-order queries, you need more.

There was no fix that I know of for Prolog. There were fixes for Datalog. Extend the language. And this was done during the last 30 years

(http://abiteboul.blogspot.com/2012/08/datalog-revival-for-da...)


>> The first scam was Prolog: The language is not really declarative.

The language is not fully declarative. It's something like 90% declarative, but that is not enough to satisfy the purists, who demand 100% purity, or else!

... or else they will stick to their C++'s and their Javas and SQLs, that are, oh, about 0.01% declarative. Because that makes sense, right? If you can't have a perfectly, purely declarative language, throw out the baby with the bathwater and go back to your purely imperative languages.

That kind of criticism has never made any sense and it doesn't make sense now.

>> But the scam is that if you want to do anything serious beyond your stupid positive first-order queries, you need more.

You can't do anything serious with Datalog? Sure you can- you can do machine learning with Datalog:

https://github.com/metagol/metagol


>> Sure you can

The author spent decades on Datalog and when he says Datalog he talks about the core Datalog not even Datalog¬, he is just stating that the core Datalog is a wonderful seed for building actual applications by extending it.


It's a secret weapon. Most folks keep their mouth shut!

Stock brokering system in New Zealand https://dtai.cs.kuleuven.be/CHR/files/Elston_SecuritEase.pdf


I knew a team trying to bridge that gap by including prolog query engines for UML models. Don't know how far it went.


I remember some friends implementing something for a business in Turbo Prolog, but I thought that had some non-standard extensions.


It did... it was compiled, and had some of the standard stuff that came with Borland's other Turbo* languages (like screen manipulation routines). Which came with a price... Turbo Prolog code is pretty much incompatible with any other Prolog version due to its use of static typing and Pascal-ish declaration sections for domains, predicates, clauses and goals.

For those who are interested, I think old manuals (and software) can be found on archive.org.


Turbo Prolog lives on as Visual Prolog: https://www.visual-prolog.com/


Sicstus Prolog claims that it's used in the transport and logistics industries, in particular, handling a third of all airline tickets worldwide:

“Most people probably have used SICStus Prolog without knowing it,” says Mats Carlsson, its lead developer. “One of our customers runs a flight booking system on SICStus which handles nearly a third of all airline tickets in the world.”

https://www.sics.se/projects/sicstus-prolog-leading-prolog-t...

A custom-made Prolog interpeter written in C, Small Prolog, was famously used in the Windows NT network configuration:

https://web.archive.org/web/20040603192757/research.microsof...

Back in the '80s and early '90s, there was a huge spike of Prolog adoption in industry, coinciding with the Fifth Generation Computer project [1]. I thought there was some data showing this clearly on the TIOBE language index, but I had a look just now and I couldn't find anything.

In any case, that was the time of rule-based expert systems and Prolog was often the language of choice for those. Anecdotal accounts in the Prolog community have long held that there are still many large-scale systems left over from that time, that were written in Prolog and in typical industry fashion have not been changed since. Having worked in the financial industry, that still runs COBOL and JCL on mainframes, I am prepared to believe this is totally the case. Some examples are listed here (sourced from an "AI expert" in 1993):

http://www.drdobbs.com/parallel/the-practical-application-of...

_______________

[1] A Japanese Ministry of International Trade and Industry project that aimed to do to the computer industry what Japanese companies had done to the car and consumer electronics industries:

https://en.wikipedia.org/wiki/Fifth_generation_computer

Their choice of technology for the next-generation computer was a parallel machine that would run a Prolog-like logic programming language natively. This was inevitably supersedd by general-purpose architectures, so it tanked, taking Prolog with it. Before that, however, Prolog received a lot of attention by industry and government in the US, who were afraid that the Japanese would once more take the lead in a new technology.

I've read a few related books from the time and they're a bit like a parallel world's history, where Prolog is the most important language for new programmers to learn and logic programming machines are about to take over the world.

Oh what cruel irony of fate, considering what soon followed.


Erlang has Prolog roots. Like Prolog, its syntax is not pretty, which has hindered wider adoption.

I wonder if Prolog is strictly necessary these days, even for uses cases in its niche, that is, logic programming. It seems one can achieve the same functionality as Prolog with an internal DSL built on top of a more mainstream language.


What is the relation of Prolog constraint programming and "Google OR-Tools" ?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: