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.

Prolog Control in Six Slides

82 pointsby nils-m-holmalmost 6 years ago

7 comments

triskaalmost 6 years ago
Very nice! A key attraction of pure Prolog code is indeed that it can be evaluated in different ways to obtain better termination and performance characteristics, and to derive more semantic consequences of programs. The equation &quot;Algorithm = Logic + Control&quot; indicates this ability to provide and use different ways of control to evaluate the logical meaning of Prolog code.<p>These slides seem to focus primarily, and in fact exclusively, on an important control mechanism called SLDNF resolution (SLD resolution with negation as failure):<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SLD_resolution" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SLD_resolution</a><p>This is the standard execution method of Prolog.<p>There are other ways to execute Prolog code too though, notably SLG resolution. SLG resolution is also called <i>tabling</i>, and it is provided by an increasing number of Prolog implementations and also in different variations. SLG resolution is a control strategy that terminates in many cases where SLDNF resolution does not terminate.<p>For example, the Prolog predicate<p><pre><code> a :- a. </code></pre> <i>terminates</i> (and fails) with SLG resolution, but not with SLDNF resolution.<p>Note that Prolog is restricted to <i>least Herbrand models</i>. This is different from answer set programming (ASP), where you get all models. For example, the above program has two models in ASP (and in logic) namely one where <i>a</i> is true and one where <i>a</i> is false, but only one least Herbrand model (where <i>a</i> is false).<p>A common criticism of Prolog is that is &quot;confined to depth first search&quot;, but that is not the case: You can reason about Prolog code in many different ways, and also execute it with iterative deepening, for example. This is in fact a major attraction of Prolog, not available in most other programming languages.<p>However, the more impure constructs you use, the more this flexibility shrinks. The ability to use different control mechanisms is a strong argument to use, as far as possible, the pure monotonic core of Prolog.
评论 #20599689 未加载
nils-m-holmalmost 6 years ago
I am the author of the paper. First of all, thank you all for the valuable feedback!<p>I (re-)discovered PROLOG only a few months ago after having learned it superficially in the 90&#x27;s. Then I wanted my own, hackable interpreter, and started to read books about PROLOG implementation. I found them to be too complex for my needs, so I finally sat down and asked myself &quot;If I were a PROLOG interpreter, what would I do?&quot; Then those six slides materialized in my head.<p>In the meantime, I have written an interpreter that is mostly compatible to DEC-10 PROLOG, have read Clocksin, Boizumault, and half of O&#x27;Keefe (and skimmed through a few others), and I am quite enjoying the tour so far! PROLOG is a fascinating language, and there are so many things to discover!
评论 #20600948 未加载
6thaccount2almost 6 years ago
PSA:<p>If you go to the author&#x27;s root page, you can see they&#x27;ve written many fascinating books on niche subjects that aren&#x27;t so niche on HN. For example, implementation of a lisp system and array programming, scheme books, logic programming stuff... etc. I haven&#x27;t bought any yet (sadly), but plan to in the future as they seem to be optimized for the self learner who wants to learn via discussion and numerous simple examples rather than chapters full of dense mathematical theory. The array programming one looks a lot better than the Dyalog book and some of the J books I own or have flipped through.
评论 #20600926 未加载
sgt101almost 6 years ago
How does this fit with answer sets?<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19663409" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19663409</a>
评论 #20599453 未加载
评论 #20599588 未加载
mawekialmost 6 years ago
Two comments:<p>1. I don&#x27;t see how this would ever fit on six slides. I mean, I see the slides but how useful&#x2F;standalone are they, even if taken as basis for presentation of that paper?<p>2. The author conflates Prolog with SLD resolution. There are other resolution schemes in prolog systems. SLD might be the one defined for the iso-prolog standard but it&#x27;s not the same. XSB and SWI support tabling and then use different schemes (SLG) and are still prolog. (Edit: see Triska&#x27;s comment for more on this. It seems we posted within seconds of each other)
dangalmost 6 years ago
The pdf is here: <a href="http:&#x2F;&#x2F;www.t3x.org&#x2F;bits&#x2F;prolog-6-slides.pdf" rel="nofollow">http:&#x2F;&#x2F;www.t3x.org&#x2F;bits&#x2F;prolog-6-slides.pdf</a>
Vivtekalmost 6 years ago
Oh man, I&#x27;m happy you&#x27;re looking at Prolog. Your writing is fantastic.
评论 #20602751 未加载