TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The Power of Prolog

348 pointsby nochabout 8 years ago

25 comments

jacquesmabout 8 years ago
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:&#x2F;&#x2F;www.redditmirror.cc&#x2F;cache&#x2F;websites&#x2F;web.archive.org_84624&#x2F;web.archive.org&#x2F;web&#x2F;20040603192757&#x2F;research.microsoft.com&#x2F;research&#x2F;dtg&#x2F;davidhov&#x2F;pap.htm" rel="nofollow">http:&#x2F;&#x2F;www.redditmirror.cc&#x2F;cache&#x2F;websites&#x2F;web.archive.org_84...</a>
评论 #14046636 未加载
评论 #14046554 未加载
fizixerabout 8 years ago
Roughly half the &#x27;power of prolog&#x27; comes from the &#x27;power of logic programming&#x27; 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&#x27;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&#x27;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&#x27;re addictive).<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Zebra_Puzzle" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Zebra_Puzzle</a><p>EDIT 3: An &quot;expert system&quot; (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.
评论 #14047151 未加载
评论 #14046569 未加载
评论 #14047560 未加载
评论 #14049671 未加载
评论 #14049120 未加载
评论 #14049060 未加载
评论 #14048782 未加载
评论 #14049766 未加载
评论 #14047157 未加载
评论 #14046661 未加载
评论 #14049139 未加载
评论 #14049134 未加载
评论 #14047334 未加载
评论 #14048000 未加载
samwalrusabout 8 years ago
I run a youtube channel called &#x27;playing with prolog&#x27; <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;channel&#x2F;UCfWpIHmy5MEx2p9c_GJrE_g" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;channel&#x2F;UCfWpIHmy5MEx2p9c_GJrE_g</a><p>We demo little things that you can do in prolog.<p>Happy to take suggestions for videos :)
hexmilesabout 8 years ago
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:&#x2F;&#x2F;www.metalevel.at&#x2F;prolog&#x2F;facets" rel="nofollow">https:&#x2F;&#x2F;www.metalevel.at&#x2F;prolog&#x2F;facets</a>):<p><pre><code> list_length([], 0). list_length([_|Ls], N) :- N #&gt; 0, N #= N0 + 1, list_length(Ls, N0). </code></pre> i don&#x27;t undestand it, i read the segment describing it multiple time but i still don&#x27;t get it, and is not the syntax i don&#x27;t undestand how it should work, a tried reading the next few chapter but i feel i&#x27;m missing something! is there a &quot;prolog for dummies&quot; out there?
评论 #14047251 未加载
评论 #14047881 未加载
评论 #14047187 未加载
评论 #14047230 未加载
评论 #14051446 未加载
评论 #14052762 未加载
haddrabout 8 years ago
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...
评论 #14047216 未加载
评论 #14048046 未加载
andaiabout 8 years ago
For an introduction to Prolog:<p>Learn Prolog Now - Free Online Version <a href="http:&#x2F;&#x2F;www.learnprolognow.org&#x2F;lpnpage.php?pageid=online" rel="nofollow">http:&#x2F;&#x2F;www.learnprolognow.org&#x2F;lpnpage.php?pageid=online</a><p>I like this one because it&#x27;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&#x27;d be happy to hear about them!
timonokoabout 8 years ago
Never understood why natural numbers (or some set of N) is not in the search space:<p>fib(X,X):- X&lt;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.
评论 #14049938 未加载
评论 #14046541 未加载
评论 #14049191 未加载
skdotdanabout 8 years ago
Something I would like to be able to understand&#x2F;know&#x2F;study is how logic programming languages are implemented and how their runtime looks like.
评论 #14048898 未加载
评论 #14048444 未加载
评论 #14048525 未加载
评论 #14049565 未加载
moderationabout 8 years ago
See the Open Policy Agent [1] project that has a language and REPL called Rego inspired by Datalog.<p>1. <a href="http:&#x2F;&#x2F;www.openpolicyagent.org&#x2F;documentation&#x2F;how-do-i-write-policies&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.openpolicyagent.org&#x2F;documentation&#x2F;how-do-i-write-...</a>
huhertoabout 8 years ago
I implemented the Wumpus World form Peter Norvig&#x27;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:&#x2F;&#x2F;github.com&#x2F;huherto&#x2F;aima3&#x2F;tree&#x2F;master&#x2F;src&#x2F;wumpus" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;huherto&#x2F;aima3&#x2F;tree&#x2F;master&#x2F;src&#x2F;wumpus</a>
lacampbellabout 8 years ago
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&#x27;t really &quot;get it&quot;. It might be worth another look now I have a bit more experience under my belt. I&#x27;ve got a lingering feeling it would solve a certain kind of problem very easily.
评论 #14048015 未加载
评论 #14047967 未加载
评论 #14048222 未加载
SagelyGuruabout 8 years ago
I used to teach Prolog in the GOFAI days of early 80&#x27;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 &quot;top-down&quot; design.
camelNotationabout 8 years ago
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.
pjonesdotcaabout 8 years ago
A great intro to Prolog can be found here if you&#x27;re not the type that learns solely from reading. <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=SykxWpFwMGs" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=SykxWpFwMGs</a>
mark_l_watsonabout 8 years ago
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.
评论 #14051482 未加载
norswapabout 8 years ago
If you want to exercise your Prolog-foo: <a href="https:&#x2F;&#x2F;github.com&#x2F;norswap&#x2F;prolog-dry" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;norswap&#x2F;prolog-dry</a>
bschwindHNabout 8 years ago
I once wanted to solve a problem that is perfect for Prolog, but I wanted it in Clojure. Turns out there&#x27;s a great library for that! I don&#x27;t think it has the full power of Prolog (I only know of Prolog and what it does but I&#x27;ve never used it), but for integer constraint programming it was a joy to work with.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;aengelberg&#x2F;loco" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;aengelberg&#x2F;loco</a>
zodiacabout 8 years ago
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&#x27;t use breadth-first search instead, to avoid those cases, but couldn&#x27;t find answers online - could someone who knows prolog better here have an answer?
评论 #14047984 未加载
评论 #14047600 未加载
nwatsonabout 8 years ago
The Japanese government spent US $400 million in the &#x27;80&#x27;s (a lot in those days) to try to jump ahead of &quot;western&quot; computer technology via its &quot;5th Generation Project&quot;. <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14047780" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14047780</a><p>The basis for it all ... Prolog.
评论 #14047837 未加载
评论 #14048082 未加载
pjc50about 8 years ago
&quot;No.&quot;<p>(Disclaimer: this is a joke referencing prolog&#x27;s default return when it can&#x27;t find a solution.)
arikrakabout 8 years ago
Question - is prolog used in the real world? I.e. are there businesses that use prolog in production?
评论 #14106727 未加载
rcgortonabout 8 years ago
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&#x2F;clojure&#x2F;related even when such a domain specific language is not pertinent.
signa11about 8 years ago
erlang syntax is prolog inspired, not sure if that&#x27;s a good thing though :)
评论 #14047054 未加载
评论 #14046769 未加载
评论 #14047838 未加载
taylorkingabout 8 years ago
love(prolog).
评论 #14053025 未加载
评论 #14048613 未加载
hota_maziabout 8 years ago
Prolog&#x27;s mathematical foundation is sound but the devil is in the details, and very soon, you encounter two of Prolog&#x27;s most glaring flaws that lead to spaghetti code worse than what even BASIC ever produced:<p>- It&#x27;s dynamically typed<p>- The cut operator
评论 #14051417 未加载