
I recommend Introduction to Algorithms [1]. Books like that can be really dry and hard to read, and they usually are, but they contain fundamental knowledge about computation that is the only way to solve some hard problems (and there are many hard problems that remain open). Leetcode problems, if they're any good, will simply be exercises based on the concepts in such books. But you won't understand the concepts just by solving the exercises.
My experience is that I spent seven or eight years coding in Prolog (that's how I roll, OK? Don't judge!) and while I had become skilled at it, I didn't really understand how it worked until I started my PhD at which point I really had to sit my bum down and read a whole load of stuff I didn't even know existed.
You'll probably say "what do I care? I'm not in academia". Yes, but you think of programming as a craft, right? And a crafts-person is happy to constantly improve his or her craft. Well, a PhD is one way to do that, sticking with industry for many years, if you can find the right positions, is another. But one way or another you'll eventually find yourself at a point where just solving coding exercises doesn't give you anything new. That's when you turn to the books. If you don't, then you should be concerned: it means you're not really advancing, not getting better in your craft.
I'd have a lot more to say about programming as a craft. Instead, let me point to Peter Norvig's timeless essay:
Teach Yourself Programming in Ten Years
https://www.norvig.com/21-days.html
And to this book by George F. Luger who introduced me to the concept of the "Master programmer":
AI Algorithms, Data Structures, and Idioms in Prolog, Lisp, and Java
https://www.cs.fsu.edu/~cap5605/Luger_Supplementary_Text.pdf
I'm also linking those for anyone else interested in that kind of thing. Happy reading.
___________
[1] It's online here:
https://edutechlearners.com/download/Introduction_to_algorit...
No idea if that's a legit download or not.
For a practically-minded programmer, I'd recommend this longer tutorial that guides you through the creation of an old-skewl text-based adventure game:
https://amzi.com/AdventureInProlog/apreface.php
As far as I remember, the tutorial should run on most Prologs without (significant?) modification.
For a more in-depth, high-level, more computer-sciency view try Marcus Triska's pages:
https://www.metalevel.at/prolog
Marcus Triska is also the author of several constraint logic programming libraries, for example:
https://www.swi-prolog.org/man/clpfd.html
Then, there's a number of textbooks. The classics are Clockin and Mellish and Bratko:
Programming in Prolog (Fifth Edition):
https://www2.cs.arizona.edu/classes/cs372/spring15/Programmi...
Prolog programing for AI
https://archive.org/details/prologprogrammin0000brat
I personally really enjoyed this book by George Luger:
AI Algorithms, Data Structures and Idioms in Prolog, Lisp and Java
https://www.cs.fsu.edu/~cap5605/Luger_Supplementary_Text.pdf
For the theory behind DCGs, there's Pereira and Shieber:
Prolog and Natural Language Analysis
http://www.mtome.com/Publications/PNLA/prolog-digital.pdf
And for logic programming theory in general, the seminal source is J. W. Lloyd:
Foundations of logic progamming
https://link.springer.com/book/10.1007/978-3-642-83189-8
Unfortunately, I can't recommend any newer texbooks.
Introduction to Automata Theory, Languages, and Computation, 2nd Ed.
https://www.amazon.co.uk/Introduction-Automata-Theory-Langua...
Which is basically all the goodness in Structure and Interpretation... and any book on compilers and interpreters. Basically, though I don't reckon that any modern courses teach from Hopcroft & Ullman, it's a major textbook in the field (unfortunately the 2nd ed is easier to find but the 1st has the works).
Another foundational text is Andrew Tennebaum's book on Operating Systems:
Operating Systems Design and Implementation
https://www.amazon.co.uk/Operating-Systems-Implementation-Pr...
To be honest I don't how it compares with the book proposed in the article, since I haven't read that book.
Finally, two personal recommendations for anyone interested in AI (as a study of advanced CS concepts and not just as a way to make a quick buck with a shallow understanding of a few machine learning tutorials):
Artificial Intelligence: A modern approach (Russel & Norvig)
And the free pdf of AI Algorithms, Data Structures, and Idioms in Prolog, Lisp, and Java:
https://www.cs.fsu.edu/~cap5605/Luger_Supplementary_Text.pdf
Which doubles as a good textbook for programming languages in general.
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).
Actually, I'd go one step further and say that in order to make full use of Prolog you need to understand SLD resolution and definite clauses, otherwise you'll never really get what the hell is going on in there, or why the interpreter works the way it works. To program in Prolog you do need a non-trivial understanding not only of its implementation but also of the substantial theoretical work that led to its implementation as the prototypical logic programming language (e.g. see J. W. Lloyd, Foundations of Logic Programming).
The thing is, there is a lot more going on with Prolog than "here is a language that can be used to control a digital computer". Logic programming is the continuation of the work of the logicians of the early 19th century, the evolution if you like of mathematical logic. It has to be understood in that context- or not at all.
You make the point that there is an operational, or imperative, reading of Prolog code, that must be understood alongside the declarative one. That is correct, in my opinion, but I don't see why it's a problem. For one thing, programmers taught on imperative languages (i.e. the majority) should not really have a problem with the operational semantics of Prolog (e.g. what you see when you trace Prolog code in the four-port tracer, the order in which goals are called, succeed, fail and are retried etc). Understanding the semantics of the cut is maybe not trivial, but again that is a problem only if someone tried to sell you Prolog as an "easy" or "friendly" language; which it isn't.
More importantly, Prolog has its declarative reading also, which is something almost unique to it. So maybe Prolog is not a perfect, pure implementation of the declarative paradigm- so what? Should we throw the baby out with the bathwater and say, hey, Prolog is only 99% declarative, so I'll just stick with Java, which is 0% declarative? That doesn't make much sense! At least not if you somehow want to use declarative programming- if not, then Prolog is not an option anyway.
>> Finally, I believe that the cut operator also makes parallel processing implementations of Prolog very difficult.
You mean parallel execution of Prolog code? Not parallel implementations of the language? I don't see that the cut is a problem there, but then again I don't have any experience trying to parallelise Prolog code. There is again a promise that Prolog's execution scheme is uniquely disposed to parallel execution. Maybe it is, maybe it isn't. But that is not the most important characteristic of Prolog.
The most important characteristic, like my previous comment says, is that Prolog is an automated theorem prover for first-order logic theories. Anything else that it may do is by the by- and, conversely, any compromise it has to do on the way there, provided we're talking about pragmatic compromises necessary to get the language to work on limited resources (i.e. like the cut), is worth it.
Of the sources you quote I'm familiar with Clocksin & Mellish, Bratko and Sterling & Shapiro. Those are good books, although Bratko probably tries a bit too hard to make Prolog sound a bit like Pascal. I would also recommend Richard O' Keefe's The Craft of Prolog and George Lugger's "AI Algorithms, Data Structures, and Idioms in Prolog, Lisp, and Java", online here:
http://wps.aw.com/wps/media/objects/5771/5909832/PDF/Luger_0...
>> Perhaps Logic Programming will make a comeback aided by the new advances in automated theorem proving.
Nah, I don't think so. I think it will remain a niche thing, of interest primarily to academics and programmers who like obscure languages. But that's OK. Not every language needs to be Java or Python.
https://www.cs.unm.edu/~luger/
(You can also find the whole book online for free but I'm not sure of the legality of that so I'm not linking to it).
There's some examples of programs implemented in both Python and Prolog on Rosetta Code, too.