The Art of Prolog, Second Edition
mitpress.mit.edu
mitpress.mit.edu
Might be useful for the folks who want to learn how the language ticks but don't have the time to go through a whole book.
That being said, the book is pretty great! I recommend it.
^^ I found to be very helpful in learning enough of Prolog to make a bracket for the 2018 World Cup
What a con, I'll be sure to avoid anything like that in future.
"Prolog is just a brute force search" -> "Prolog is a brute force search"
and then reference the Gary Larson comic ( https://pics.me.me/the-far-side-by-gary-larson-3-23-hey-wait... ) where the cow suddenly realises what they've been eating is /grass/.
All libraries are "just" some code which does something so you don't have to. Even if Prolog is "just a brute force search", well in the same kind of way, regex is "just" a state machine brute-force matching against a string. It's still a useful tool.
But yeah, it involves quite a lot of backtracking, that happens when the resolution engine needs to go back and try something different. When this is a problem you can sometimes use the cut rule http://www.cse.unsw.edu.au/~billw/dictionaries/prolog/cut.ht...
Prolog should also be very popular with developers who like pattern matching and destructuring; it's pattern-matching by unification is, er, unmatched.
Prolog is also excellent for DSLs, either usings it's built-in facility for defining new functors (unary or binary operators/keywords), or standard DCG recursive-descent parsers or more complex grammars. Prolog was designed for NLP, used for prototyping Erlang, and a major inspiration for Haskell after all.
The art of efficient in prolog is understanding your database, facts, and your search space and how to trim it. If you need 3 items, search for 3 items only, don't search for all possible items then try to pick 3.
If you can figure out when to cut your search, do so.
For deterministic operations that you can meomize, do so.
If your system supports tabling use it.
Difference list is like the TCO of Prolog, the efficiency can be amazing.
The difference in performance between an average programmer and a pro prolog programmer is usually much more than you will find in other languages.
'Paradigms of Artificial Intelligence Programming' by Peter Norvig[0]. The book teaches both LISP and classic AI.
CHR (constraint handling rules) is a forward chaining system built into most prologs that has prolog like syntax, and so is a replacement for business rules engines.
So the choice of what to use is based on that (if you want forward chaining - business rules, or CHR of prolog), if you want backward chaining (similar to SQL) then prolog.
Prolog is more elegant than the business rules engines, and also has extra features (constraint programming with finite domains for example), that business rules don't have.
So in short, prolog is more comprehensive and more elegant but requires more expertise, busines rules are for "untrained" people to get working with relatively quickly.
https://www.cse.unsw.edu.au/~billw/cs9414/notes/kr/rules/for...
Allows for rules such as
iF
problem_in_kitchen and no_water_from_outside
then
leak_in_kitchen.TLDR: learn Prolog
It's like driving a truck and then learning to try a sports car cautiously like an overloaded truck, you won't enjoy it!
Lispers love to talk about "code is data" In prolog, "data is code" and until you grok that, it's really difficult to experience the Prolog enlightenment.
The drawback of metainterpretation is that it is, well, an interpreter layered on top of (on many systems) another interpreter. If you need your Prolog code to be really really "fast", then this approach may be "too slow". (Quotes because people love complaining about the speed of computation even in many situations where it really does not matter.)
A different approach is to use code generation. Prolog programs are collections of Prolog terms; once you have written the abstract computation you want, you can write a program that takes that code, mangles it into a different form, then compiles that new form just as if you had written it by hand.
So in summary, the separation you ask for is not there, but you have much more powerful tools than most other languages to implement it yourself quite easily.
You can encode your facts in prolog style syntax and save it in a file and that's your database. You load it, and then ask your questions at the REPL.
If you wanted data that multiple people can change, you can actually connect prolog to an SQL database, then using query apply prolog rules and ask questions about your data.
You're probably looking for Datalog. The Wikipedia topic has a list of systems that support it: https://en.m.wikipedia.org/wiki/Datalog
Also, I found that AllegroGraph is a production graph database that supports Prolog queries... I don't think you load it with Prolog syntax, though--probably RDF triples instead.
https://en.wikipedia.org/wiki/Strand_(programming_language)
https://www.amazon.com/Strand-New-Concepts-Parallel-Programm...
I have a copy of the book, and the code samples are really similar to Erlang.
A good description of what it's about is at MIT Press' page for the author [1].
(While out-of-print, apparently a paperback version can be had for $21 on Amazon [2]).
[0] http://wambook.sourceforge.net/
[1] https://mitpress.mit.edu/contributors/hassan-ait-kaci
[2] https://www.amazon.com/Warrens-Abstract-Machine-Reconstructi...
https://github.com/rm-hull/wam (WAM in Clojure)
https://github.com/rupertlssmith/hak_wambook (WAM in Java)
Can someone say which (who?) are the "Prolog for the 21st century" and the "Lisp of the 21st century" ?!
"when the proof search accidentally returns the trivial case"
Tutorial available here (the "Ralph Becket Murcury tutorial" pdf) http://mercurylang.org/documentation/documentation.html
And just to tie this back to the original topic, Leon Sterling (first author of The Art of Prolog) was the head of the Department of Computer Science at the University of Melbourne when the development of Mercury began there.
Also, using the SICStus interface and semantics for attributed variables should make for some very general constraint solvers, yes.
and both in open access~