7 ms·
The Art of Prolog, Second Edition
- pstuart 8y agoClearly the universe wants me to learn Prolog, as HN seems to be putting it on the front page almost every day. Challenge accepted.
- crazybigdan 8y agohttp://lpn.swi-prolog.org/lpnpage.php?pageid=online http://lpn.swi-prolog.org/lpnpage.php?pageid=online ^^ I found to be very helpful in learning enough of Prolog to make a bracket for the 2018 World Cup
- ggggtez 8y agoAs long as you know that Prolog is just a fancy wrapper around a brute force search, then sure.
- deleted 8y ago[deleted]
- tr352 8y agoUncalled for. Yes you can implement brute force search very conveniently in Prolog but there's obviously much more to it. You can dismiss ML in a similar way: It's fine as long as you know that it's just glorified curve fitting.
- jodrellblank 8y ago"Hey! I just found out - that tool isn't magic, it's JUST CODE!" What a con, I'll be sure to avoid anything like that in future.
- jodrellblank 8y agoCan't edit or delete at this point, so I'll note that I see this is against the "no snark" rule, and what I wanted to do was link to the c2.com wiki page "JustIsaDangerousWord" - a page that's now offline - about how a sentence gets better if you remove the word "just". "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-a-2526411.png 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.
- newacctjhro 8y agoResolution isn't really brute force search, in that it doesn't search all possible solutions at random; the search is directed by the programmer's rules. 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.html http://www.cse.unsw.edu.au/~billw/dictionaries/prolog/cut.ht...
- tannhaeuser 8y agoProlog hits a sweet spot where you can start with built-in resolution and then use Prolog as implementation language for specific searches. 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.
- segmondy 8y agoNo it's not. Might as well say that SQL is a brute force search against your database. If you don't add indexes, you end up with slow queries. 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.
- yazr 8y ago1986 Art of Prolog.. Can someone say which (who?) are the "Prolog for the 21st century" and the "Lisp of the 21st century" ?!
- radiator 8y agoHmmm... perhaps Prolog and Lisp?
- yazr 8y agoAs in, "fill-in-the-spaces will soon free us from the tyranny of imperative programming"...
- paulmd 8y ago> Hmmm... perhaps Prolog and Lisp? "when the proof search accidentally returns the trivial case"
- protomyth 8y agoLike in The Reasoned Schemer? https://mitpress.mit.edu/books/reasoned-schemer https://mitpress.mit.edu/books/reasoned-schemer
- simplify 8y agoMercury is a promising logic programming language that's under development https://github.com/Mercury-Language/mercury https://github.com/Mercury-Language/mercury Tutorial available here (the "Ralph Becket Murcury tutorial" pdf) http://mercurylang.org/documentation/documentation.html http://mercurylang.org/documentation/documentation.html
- timb07 8y agoThe Mercury compiler is written in Mercury, which is syntactically derived from Prolog. The original compiler was bootsrapped by stripping the non-Prolog parts from the code and executing it on NU-Prolog. The compiler first successfully compiled itself in 1995, after which NU-Prolog was no longer needed. 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.
- zura 8y agoI'd put it on a par with SICP. A very enjoyable reading.
- agumonkey 8y agonote the 1st edition is also up there https://mitpress.mit.edu/books/art-prolog https://mitpress.mit.edu/books/art-prolog and both in open access~
- overcast 8y agoA link to a bookstore summary page about a programming book makes front page HN?
- Jtsummers 8y agoIt was discussed some yesterday, and the ebook is free.
- overcast 8y agoSo this a duplicate topic, and it's just a link to a free ebook? Slow day on HN I guess.
- Jtsummers 8y agoRelated topic that the poster thought deserved its own link. Prior discussion was yesterday. https://news.ycombinator.com/item?id=18178215 https://news.ycombinator.com/item?id=18178215
- tannhaeuser 8y agoCheckout "Download PDF" under the "Open Access Title" heading.
- gambler 8y agoI learned the basics of Prolog, really liked the idea, but found it rather impractical for complex problems. IMO, there needs to be a stronger separation between rule descriptions and search algorithm description/manipulation. I want to be able to specify an infinitely recursive rule, but avoid falling down the rabbit hole while running queries. Cuts could also be moved into this "search algorithm description".
- ggggtez 8y ago>infinite recursion >finite runtime I think there is a bug in between the keyword and the chair.
- KirinDave 8y agoFunctional programmers work with infinitely recursive structures and data all the time and it doesn't really bother them, so this isn't automatically an absurd thing to say. Just because structures, rules and trees are infinitely recursive doesn't mean no insight can be created from them in finite time.
- cgrand-net 8y agoNot necessarily. One can use tabling (memoization) to prevent that. Also sometimes reordering clauses in the body of a rule is enough to avoid infinite runtime. Datalog (or SQL + recursive CTE) don't have this problem. Mozart/Oz or Alice allow to specify the search strategy.
- GavinMcG 8y agoOther people are explaining why you're wrong, but I'd like to point out that even if you were right, your comment would still be nearly worthless. Merely pointing out that someone else isn't correct might even have negative net value. For one thing, it can be construed as simple disagreement, opening up a debate that shouldn't happen when there really is a definitive answer. For another, it's insulting (especially as you did it) and that's not a necessary part of correcting someone's understanding. Invest a few more minutes next time to actually make a substantive comment. You'll be helping the person you correct, you'll be helping whoever else reads the thread, and you'll ultimately be helping yourself – by opening up your views to an actual constructive process.
- keithnz 8y agoIs there any good resources for the internals of prolog / writing a prolog interpreter?
- Tistel 8y agoPeter Norvig (of google fame) describes how to write a prolog like language in Common Lisp: https://www.amazon.ca/Paradigms-Artificial-Intelligence-Programming-Studies/dp/1558601910/ref=sr_1_4?ie=UTF8&qid=1539204305&sr=8-4&keywords=Peter+norvig https://www.amazon.ca/Paradigms-Artificial-Intelligence-Prog...
- qohen 8y agoMIT Press published a book called "The Warren Abstract Machine: A Tutorial Reconstruction" by Hassan Ait-Kaci. This short -- 114 pages -- book about the Prolog VM has been made available for free download by the author (it's out-of-print). [0] 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/ http://wambook.sourceforge.net/ [1] https://mitpress.mit.edu/contributors/hassan-ait-kaci https://mitpress.mit.edu/contributors/hassan-ait-kaci [2] https://www.amazon.com/Warrens-Abstract-Machine-Reconstruction-Programming/dp/0262510588 https://www.amazon.com/Warrens-Abstract-Machine-Reconstructi...
- tmaly 8y agoI still have my copy on my desk, this and a few other Prolog books I found very useful when I first started trying to grok the language.
- linsomniac 8y agoThe original Art of Programming I read when I was ~16, and I found to be extremely influential in how I thought of programs and data and their interrelation.
- mark_l_watson 8y agoI keep my copy on my bookshelf - it is really an elegant book for an elegant language.
- jayd16 8y agoI ask this seriously. Does it make more practical sense to learn a modern business rule engine (like JBOSS BRMS) than to learn Prolog?
- overlords 8y agoRules engines are about forward chaining (fan-out of all implications) whereas prolog is backward chaining (querying an implication). 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.
- pgtan 8y agoI went from logic puzzles to Prolog and the CLPFD lib was a great help to achieve results even as novice.
- segmondy 8y agoBuilding a forward chaining rule in Prolog is trivial. Here's an example in 25 lines https://www.cse.unsw.edu.au/~billw/cs9414/notes/kr/rules/forward.pro 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.
- garmaine 8y agoIf you are actually interested in learning and understanding, rather than just blinding following stack overflow procedures to solve instances of templated problems, then I would highly recommend a simpler language like Prolog, a theory-oriented text like the Art of Prolog.
- 8y ago
- Tistel 8y agoI had heard about prolog for years, but, it was not taught at the university I went to. But, as other have mentioned, I have always wondered about it, hearing whispers here and there. The recent resurgance of interest came from working with Erlang. Erlangs syntax is from Prolog (because it was prototyped in Prolog first) I am reading the basic intro text: https://www.amazon.ca/Programming-Prolog-Using-ISO-Standard/dp/3540006788/ref=sr_1_1?ie=UTF8&qid=1539208185&sr=8-1&keywords=prolog https://www.amazon.ca/Programming-Prolog-Using-ISO-Standard/.... which is nice. All I can say is, its very strange and interesting.
- jlarocco 8y agoAlthough prototyped in Prolog, Erlang borrowed heavily from an obscure language called Strand. https://en.wikipedia.org/wiki/Strand_(programming_language) https://en.wikipedia.org/wiki/Strand_(programming_language) https://www.amazon.com/Strand-New-Concepts-Parallel-Programming/dp/013850587X 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.
- norswap 8y agoI'm plugging my own Prolog tutorial: http://norswap.com/prolog-served-dry/ http://norswap.com/prolog-served-dry/ 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.
- nafizh 8y agoMandatory plugin for learning lisp. 'Paradigms of Artificial Intelligence Programming' by Peter Norvig[0]. The book teaches both LISP and classic AI. [0] https://github.com/norvig/paip-lisp https://github.com/norvig/paip-lisp
- dreamcompiler 8y agoWhich among other things teaches you how to write a Prolog compiler in Lisp.
- agumonkey 8y agoAight, tonight's reading. Thanks.
- CMCDragonkai 8y agoIs there a production database where I can encode facts and logical policies in prolog style syntax then perform inference via the database?
- segmondy 8y agoYes, your production database is a text file really. 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.
- mbravenboer 8y agoLogicBlox more or less did that, though restricted to Datalog with various extensions. It's a commercial system though and not publicly available, except for online training material. See https://developer.logicblox.com/playground/ https://developer.logicblox.com/playground/ (since you probably don't know what to do, it's best to go to https://developer.logicblox.com/content/docs4/tutorial/repl/section/split.html https://developer.logicblox.com/content/docs4/tutorial/repl/... )
- markdoubleyou 8y agoI've been looking at this, too, after the recent surge in HN Prolog headlines. You're probably looking for Datalog. The Wikipedia topic has a list of systems that support it: https://en.m.wikipedia.org/wiki/Datalog 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.