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:
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):
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.
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.
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/
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 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?
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].
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
>> 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:
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 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.
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.”
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):
[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:
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.