[HN Gopher] The Power of Prolog ___________________________________________________________________ The Power of Prolog Author : fogus Score : 124 points Date : 2020-04-07 15:27 UTC (1 days ago) (HTM) web link (www.metalevel.at) (TXT) w3m dump (www.metalevel.at) | collyw wrote: | Prolog look like it would be the correct tool for the job for a | certain class of problems, I wish I had time to learn it. I | always wonder why it doesn't get more attention. | sacado2 wrote: | Nowadays, ontology-management systems like Protege and SPARQL | can more or less solve all problems prolog can solve, while | providing higher-level formalisms and with the guarantee your | query will terminate. | baq wrote: | i've never used prolog seriously despite having a few | problems very well suited for declarative solutions - | variants of job shop scheduling, rule based workflows, etc. | most reasons for why prolog didn't take off in my job are | non-technical - it looks weird, it's hard to debug, | integration with python isn't obvious and one worry i had | (never tested) was that while the idea is to tell the | computer about the problem, the real art was placing cuts. | tejtm wrote: | Hmm programs terminating because Protege is guaranteed to | slag your machine is a feature had overlooked. | Avshalom wrote: | > I wish I had time to learn it. I always wonder why it doesn't | get more attention. | | pre-answered your own question really. Prolog 'died' in the AI | winter, so no one knows it and no one knows anyone who knows | it. Every time you think "huh I bet this is like 100 lines in | Prolog" it doesn't matter because writing 2000 lines of Java | (or whatever you know) is still going to be faster than | learning Prolog. | | This is also the problem with literally any comment about | "using the right tool for the job" with regards to programming | languages. | triska wrote: | Complementing this, neural nets shared the same fate in an AI | winter, in fact in the AI winter preceding the one you | mention, and yet they now attract significant attention. In | large part because the hardware is better, and also because | the approaches are now better. | | We may see analogous developments with Prolog when our | current hardware gets better or changes its characteristics, | and when Prolog implementations get better and use better | approaches that are now becoming available. | | I think one difficulty we are facing when judging | developments in this area is that complex software projects | such as implementing a Prolog system happen on time scales we | are not yet used to. | Avshalom wrote: | Personally I think Prolog is great* and I'm learning it for | funsies but neural nets are a specific approach that people | have been writing in Python, because they already know | Python. Prolog is a whole thing. Kind of an apples and | oranges problem. | | * I mean seriously it's fantastically expressive: parsing, | constraint logic, expert systems, database interaction-- | all look and _feel_ completely native, it 's beautiful. | triska wrote: | Absolutely, I fully agree! | | In fact, I think precisely due to this elementary | difference, it is reasonable to expect it to take longer | for Prolog implementations to reach the practical | applicability we are now seeing in neural networks after | a few decades of research and improvements. | [deleted] | deckard1 wrote: | I think the reason no one uses Prolog is simply because | generalized backtracking problems (i.e. the problems you | would use Prolog for) are too computationally expensive and | infrequent enough that: | | a) You would never train staff or hire experts on Prolog for | such few problems and... | | b) You could probably do much better with a heuristic | algorithm anyway. Especially on hardware of the day when | Prolog came out, but even today I imagine this holds true. | | Prolog may be useful for quick exploration of a problem | space. But for code that needs to run frequently, there just | isn't a great need for what Prolog has to offer. | girzel wrote: | I'm guessing because it's so fundamentally different from most | of the other programming languages out there, which I sometimes | think are just variations on the variable/function/control flow | theme (and yes, I've gone fairly far in Lisp). | | I've been teaching myself Prolog, and it's sufficiently | different that I feel like I'm learning to program all over | again. You can sort of pretend that predicates are just funny | functions, where you have to put the return value's container | into the argument list, but that's not really what's going on. | I loved reading the docs for SWI-Prolog, where most of the | predicate docstrings start: "True if...". You can say that the | length predicate returns the length of a list, but really it | returns true if the given list has a length equal to the given | integer. It will tell you the length of a list, sure, but it | will also do the reverse: | | ?- length(List, 5) -> List = [_,_,_,_,_] | | Nuts! | agumonkey wrote: | ever seen Friedman and Byrd talk about kanren ? | ? evalo(e, 6) (+ 3 3) | girzel wrote: | Double nuts! | galaxyLogic wrote: | A related question is why do we still have SQL databases when | everybody could be using Datalog? | | https://en.wikipedia.org/wiki/Datalog | jplane wrote: | Take a look at datomic, it uses datalog. | downerending wrote: | I absolutely loved Prolog and CLP(R) back in the day. | | The one thing I never got past was its difficulty in dealing with | large, mutable sets of data. So, for example, given an array of a | million or billion elements that are being rapidly modified, even | the most trivial sorts of backtracking become infeasable. Maybe | there's some elegant way to do it, but I never got it. | | (And difference lists need to die.) | haolez wrote: | I've found this channel a few months ago and my wife thinks I'm | crazy when I'm watching it. "This looks like work, but harder!!". | Awesome content! Thanks for posting it :) | triska wrote: | Thank you so much, and you are welcome! That's an awesome | slogan! | | Some things are hard, yet have no pay-off or are even | detrimental. On the other hand, things that pay off are often | proportionally hard. | | It is not may goal to make it hard, in fact I am doing | everything I can to make it as easy as possible. I am very | interested in didactic approaches, and always welcome feedback! | I would like to make it worth the effort for viewers, and -- | beyond that -- exceed the required effort in value. | haolez wrote: | You do a very good job making it approachable. I'll make a | PoC this year using Prolog in a specific application | regarding contract generation (LawTech). It's surely thanks | to your insights! | | Now that I know your handle, I'll ping you when I have some | news :) | dang wrote: | Earlier versions were discussed in 2018: | https://news.ycombinator.com/item?id=17121028 | | and 2017: https://news.ycombinator.com/item?id=14045987 | | (Links are for the curious. Reposts are ok after a year: | https://news.ycombinator.com/newsfaq.html) | triska wrote: | Thank you very much for your interest, I greatly appreciate it! | | I hope you are all doing reasonably well. Please take care! | | This book was most recently discussed here in May 2018: | | https://news.ycombinator.com/item?id=17121028 | | Since then, I have added a new chapter, _Logical Foundations of | Prolog_ : | | https://www.metalevel.at/prolog/logic | | Also, I have made several other additions and improvements. You | can see most of the changes since the last discussion in a public | git repository: | | https://github.com/triska/the-power-of-prolog/compare/8a94ed... | | Currently, I am working on several videos that will eventually | form the core of the book. Here are a few previews: | | https://www.metalevel.at/prolog/videos/logic | | https://www.metalevel.at/prolog/videos/timetabling | | https://www.metalevel.at/prolog/videos/sparrows_on_eagles | | These videos are all work in progress, and they may be replaced | by better versions at any time. Hence, if possible, please use | the links above to refer to them: They will always point to the | latest versions. | | Alternatively, please use the following overview page that shows | all videos: | | https://www.metalevel.at/prolog/videos/ | | Also, I have published a comprehensive journal paper about my | CLP(B) system, i.e., a _SAT solver_ with some nice algebraic | properties, seamlessly integrated into Prolog as a specialized | form of unification: | | https://www.metalevel.at/boolean.pdf | | For Prolog application programmers and system implementors, the | paper's appendices may be especially interesting. They formalize | a few important concepts that are also a major theme in the book. | | As of October 2019, the CLP(B) system is also available in Mark | Thom's Scryer Prolog. Scryer is a Rust-based Prolog | implementation that is freely available, conforms to the Prolog | ISO standard, represents strings efficiently as lists of | characters, and includes important features for implementing | Prolog-based constraint solvers: | | https://github.com/mthom/scryer-prolog | | As of a few days ago, Scryer Prolog also ships with my | implementation of CLP(Z), Constraint Logic Programming over | _integers_. This is a very useful declarative paradigm for | solving combinatorial tasks, in some ways superior to SAT solving | because it allows more convenient modeling, easier | experimentation with different formulations, and reasoning at a | higher conceptual level. The chapter on declarative integer | arithmetic contains more information, and further pointers: | | https://www.metalevel.at/prolog/clpz | | For illustration, here is an example page where you can solve | _timetabling instances_ with this approach: | | https://www.metalevel.at/prolog/timetabling/ | | I welcome all comments and suggestions about the book, these | videos, and Prolog in general. Also, I would like to take this | opportunity to thank all readers for your thoughtful comments and | endorsements. Your feedback and encouragement are making this | work especially worthwhile. | | Enjoy! | wwweston wrote: | > Scryer is a Rust-based Prolog implementation that is freely | available | | ! | | As well as an exclamation I suppose that's the cut on my "write | a prolog to learn rust" predicate, backtracking to finding out | more about this, especially since I just came across a little | puzzle for which integer constraint programming is perfect this | week. | carapace wrote: | I want to say _thank you_ , for your book and for all the work | you're doing promoting and improving Prolog. | triska wrote: | You are very welcome! | | I greatly enjoy all your postings about your Prolog-based | interpreter for Joy: | | https://osdn.net/projects/joypy/scm/hg/Joypy/blobs/tip/thun/. | .. | | I impulsively upvote this every time I see it. Thank you for | sharing such an interesting project! ___________________________________________________________________ (page generated 2020-04-08 23:00 UTC)