One of the nicest examples of the power of prolog is that Windows NT contained a prolog implementation to take care of network configuration, replacing the previous codebase:<p><a href="http://www.redditmirror.cc/cache/websites/web.archive.org_84624/web.archive.org/web/20040603192757/research.microsoft.com/research/dtg/davidhov/pap.htm" rel="nofollow">http://www.redditmirror.cc/cache/websites/web.archive.org_84...</a>
Roughly half the 'power of prolog' comes from the 'power of logic programming' and prolog is by far not the only logic programming language, e.g.,<p>- You can do logic programming using minikanren in scheme. (you can also extend the minikanren system if you find a feature missing).<p>- Minikanren was implemented in clojure and called core.logic.<p>- It was also ported to python by Matthew Rocklin I think, called logpy.<p>- There is also datalog, with pydatalog it's python equivalent.<p>- Also pyke. And so on.<p>Plus logic programming has very important (arguably necessary) extensions in the form of constraint-logic-programming (CLP), inductive-logic-programming (ILP), and so on.<p>It's a huge area.<p>EDIT: ILP at an advanced level starts making connections with PGMs (probabilistic graphical models) and hence machine learning, but its a long way to go for me (in terms of learning) before I start to make sense of all these puzzle pieces.<p>EDIT 2: You can have a taste of logic programming without leaving your favorite programming language. Just try to solve the zebra puzzle [1] (without help if you can, esp. through any of Norvig posts or videos; they're addictive).<p>[1] <a href="https://en.wikipedia.org/wiki/Zebra_Puzzle" rel="nofollow">https://en.wikipedia.org/wiki/Zebra_Puzzle</a><p>EDIT 3: An "expert system" (a term from the 1980s) is largely a logic programming system paired up with a huge database of facts (and probably some way of growing the database by providing an entry method to non-programmer domain experts).<p>EDIT 4: In other words, logic programming (along with other things like graph search etc) is at the core of GOFAI (good old fashioned AI), the pre-machine-learning form of AI, chess engine being a preeminent example of it.
I run a youtube channel called 'playing with prolog' <a href="https://www.youtube.com/channel/UCfWpIHmy5MEx2p9c_GJrE_g" rel="nofollow">https://www.youtube.com/channel/UCfWpIHmy5MEx2p9c_GJrE_g</a><p>We demo little things that you can do in prolog.<p>Happy to take suggestions for videos :)
i have always trouble understaing prolog, lot of guide online seem to just tackle the syntax or assume you already know a lot of logic programming, for example the first example in the link (<a href="https://www.metalevel.at/prolog/facets" rel="nofollow">https://www.metalevel.at/prolog/facets</a>):<p><pre><code> list_length([], 0).
list_length([_|Ls], N) :-
N #> 0,
N #= N0 + 1,
list_length(Ls, N0).
</code></pre>
i don't undestand it, i read the segment describing it multiple time but i still don't get it, and is not the syntax i don't undestand how it should work, a tried reading the next few chapter but i feel i'm missing something!
is there a "prolog for dummies" out there?
There is a class of problems which you can solve using Prolog with pure pleasure.<p>There is one thing however: Prolog can magically hide the complexity of many things, which is a two-sided sword. On many occasions you are hiding away the computational complexity and wonder why the execution is so slow. This rarely happens in imperative languages (where you are more aware of all the loops and recursions). I guess this is why many people hate Prolog...
For an introduction to Prolog:<p>Learn Prolog Now - Free Online Version <a href="http://www.learnprolognow.org/lpnpage.php?pageid=online" rel="nofollow">http://www.learnprolognow.org/lpnpage.php?pageid=online</a><p>I like this one because it's beginner-friendly (and uses characters from Pulp Fiction as examples).<p>-- edit: actually, The Power of Prolog to is great, too!
If anyone knows more good resources, I'd be happy to hear about them!
Never understood why natural numbers (or some set of N) is not in the search space:<p>fib(X,X):- X<2.<p>fib(X,Y1+Y2):- fib(X-1,Y1),fib(X-2,Y2).<p>I tried to get answer to this kwestion in reddit, but all I got was personal insults.
Something I would like to be able to understand/know/study is how logic programming languages are implemented and how their runtime looks like.
See the Open Policy Agent [1] project that has a language and REPL called Rego inspired by Datalog.<p>1. <a href="http://www.openpolicyagent.org/documentation/how-do-i-write-policies/" rel="nofollow">http://www.openpolicyagent.org/documentation/how-do-i-write-...</a>
I implemented the Wumpus World form Peter Norvig's AIMA using different techniques. I found that Bayesian Logic was much more powerful than Logic programming. Perhaps that explains why Prolog has flourished.<p>Logic programming is limited to values of true or false. 0 or 1. Bayesian logic can deal with uncertainty values like .2 or .3. It almost seems like a superset. It is also more intuitive IMHO.<p>I keep the wumpus implementation here if anyone is interested.
<a href="https://github.com/huherto/aima3/tree/master/src/wumpus" rel="nofollow">https://github.com/huherto/aima3/tree/master/src/wumpus</a>
Can anyone give examples of the kinds of problems prolog is ideally suited to? I took a course on it at university. It looked interesting but I didn't really "get it". It might be worth another look now I have a bit more experience under my belt. I've got a lingering feeling it would solve a certain kind of problem very easily.
I used to teach Prolog in the GOFAI days of early 80's. It certainly was fun and probably the quickest way how to start solving interesting search based problems without having to write pages and pages of code. It was very good for motivation. Also for encouraging "top-down" design.
One of my professors in college was an original creator of the Prolog language. He made us learn Prolog so that he could teach us something we could have just as easily done in C or Java. I strongly disliked him. For that reason, I am filled with negative vibes when I think about Prolog.
A great intro to Prolog can be found here if you're not the type that learns solely from reading.
<a href="https://www.youtube.com/watch?v=SykxWpFwMGs" rel="nofollow">https://www.youtube.com/watch?v=SykxWpFwMGs</a>
I bookmarked this. I have been revisiting my own programming history. I used Prolog a lot in the 1980s, partially because I was influenced by the ill-fated Japanese 5th generation project. A few weeks ago I pulled my old Prolog code experiments from an old repo. Prolog is a great language for some applications, and Swi-Prolog has some great libraries and sample programs.<p>I also have used Common Lisp a lot since the 1980s and I am in the process of working through a few of the classic text books, and I have it on my schedule to update my own CL book with a second edition.
If you want to exercise your Prolog-foo: <a href="https://github.com/norswap/prolog-dry" rel="nofollow">https://github.com/norswap/prolog-dry</a>
I once wanted to solve a problem that is perfect for Prolog, but I wanted it in Clojure. Turns out there's a great library for that! I don't think it has the full power of Prolog (I only know of Prolog and what it does but I've never used it), but for integer constraint programming it was a joy to work with.<p><a href="https://github.com/aengelberg/loco" rel="nofollow">https://github.com/aengelberg/loco</a>
I wrote some prolog for a PL class recently and had to debug some cases of nontermination caused by the depth-first-search unification algorithm. I was wondering why prolog (or some other logic programming language) couldn't use breadth-first search instead, to avoid those cases, but couldn't find answers online - could someone who knows prolog better here have an answer?
The Japanese government spent US $400 million in the '80's (a lot in those days) to try to jump ahead of "western" computer technology via its "5th Generation Project". <a href="https://news.ycombinator.com/item?id=14047780" rel="nofollow">https://news.ycombinator.com/item?id=14047780</a><p>The basis for it all ... Prolog.
The power: require a rethink of approaches to programming
The failure: the claim by such folk that all compute problems are best solved by prolog/clojure/related even when such a domain specific language is not pertinent.
Prolog's mathematical foundation is sound but the devil is in the details, and very soon, you encounter two of Prolog's most glaring flaws that lead to spaghetti code worse than what even BASIC ever produced:<p>- It's dynamically typed<p>- The cut operator