Live data from Hacker News

Ask HN: Who/What will do for Prolog what Clojure has done for Lisp?

news.ycombinator.com

11–20 of 20 posts

Re: Ask HN: Who/What will do for Prolog what Clojure has done for Lisp?

#11
Nothing. Lisp's a general purpose multi-paradigm programming language, while Prolog isn't.

If you need a rules engine, great, but there's no reason to shoe-horn general programming problems into the Prolog model.

If you have JESS / Java or CLIPS / C, or generally, a rules engine for your favourite language, what does Prolog bring to the table?

Re: Ask HN: Who/What will do for Prolog what Clojure has done for Lisp?

#12
post #3

Prolog has its limitations, but it still stands out as one of the oldest, influential and important declarative programming languages. IMHO, it's hard to say what is the natural successor to Prolog. For all that it shares with Lisp, it definitely has never shared even a fraction of the popularity. They have two entirely different approaches and purposes though, so this isn't terribly surprising. Even if someone does…

I've also switched to ASP, largely because of choice rules plus filtering. You can write things like:

   { active(A) } :- thing(A).
Which says that for all things A, active(A) is a free choice of true or false, constrained by the requirement to be consistent with all other clauses in the program. That lets you do abductive reasoning, e.g. find an explanation, plan, or cause from a possibility space, consistent with the other asserted facts.

You an also write pure constraints, like:

   :- active(duck), active(cat).
Which says to reject all answers in which both duck and cat are simultaneously asserted active. This allows an overgenerate-and-filter style of programming, where you use choice rules to generate everything in a possibility space, and then constraints to filter out the ones you don't want. Prolog doesn't really naturally support that style of programming, though certain kinds can be hacked in with Prolog+CHR, or with one of the CSP extensions.

The main downside in my experience is that ASP doesn't do well on large programs, even large-but-simple ones that Prolog handles well, due to the fact that ASP is grounding everything to the moral equivalent of giant SAT problems. Particularly if you use numerical reasoning over non-tiny ranges. Say, you have some sprites on a grid, and at each time, each sprite has exactly one X/Y position:

   canvas_x(0..799).
   canvas_y(0..599).
   timestep(0..99).
   sprite(mario;luigi;babomb).
   1 { pos(S,X,Y,T) : sprite(S) : canvas_x(X) : canvas_y(Y) } 1 :- timestep(T).
A program like that totally blows up due to the 800 x 600 x 100 x 3 ground instantiations of pos, particularly if pos is then referenced in a lot of other rules. Since Prolog doesn't ahead-of-time compute all the ground instantiations, it can avoid that in certain classes of programs (in this case, you'd memoize the one pos per sprite/timestep once you find it, then use the cut operator to fail-fast on any other queries). There are papers on avoiding this via a new generation of "first-order ASP" not based on propositional grounding, but afaik no implementations exist.

Re: Ask HN: Who/What will do for Prolog what Clojure has done for Lisp?

#13
post #3

Prolog has its limitations, but it still stands out as one of the oldest, influential and important declarative programming languages. IMHO, it's hard to say what is the natural successor to Prolog. For all that it shares with Lisp, it definitely has never shared even a fraction of the popularity. They have two entirely different approaches and purposes though, so this isn't terribly surprising. Even if someone does…

10 or 11 years ago, David Warren was working on an extension called Tabled Logic Programming; his implementation was called XSB. He seems to have abandoned it, which I find disappointing; it looked interesting. In a nutshell, instead of a goal acting like a procedure call as in Prolog, it acts like a coroutine.

Here's a link: http://www.cs.sunysb.edu/~warren/xsbbook/book.html

Re: Ask HN: Who/What will do for Prolog what Clojure has done for Lisp?

#14
post #9

While not familiar with Prolog, I understand that Erlang's pattern matching comes from that world - so Erlang? EDIT: Here's a couple references for the Erlang/Prolog connection... http://www.erlang.org/faq/academic.html http://hyperpolyglot.org/logic Also I found this while looking for the reference for the Prolog/Erlang connection... http://www.slideshare.net/adorepump/learning-erlang-from-a-p...

Prolog's unification is quite a bit more powerful than Erlang's pattern matching, though. You can't pass around uninstantiated variables in Erlang. Erlang also discarded backtracking (because it mixes poorly with concurrency).

Re: Ask HN: Who/What will do for Prolog what Clojure has done for Lisp?

#15
post #3

Prolog has its limitations, but it still stands out as one of the oldest, influential and important declarative programming languages. IMHO, it's hard to say what is the natural successor to Prolog. For all that it shares with Lisp, it definitely has never shared even a fraction of the popularity. They have two entirely different approaches and purposes though, so this isn't terribly surprising. Even if someone does…

I've also switched to ASP, largely because of choice rules plus filtering. You can write things like: { active(A) } :- thing(A). Which says that for all things A, active(A) is a free choice of true or false, constrained by the requirement to be consistent with all other clauses in the program. That lets you do abductive reasoning, e.g. find an explanation, plan, or cause from a possibility space, consistent with the…

The wikipedia page didn't really shed much light on what ASP is doing under the hood. How does it differ from constraint solvers like http://www.gecode.org/ ? I know that gecode can handle problems like your canvas example well by representing integer variables as sets of intervals. What kind of problems would ASP have the advantage on?

Re: Ask HN: Who/What will do for Prolog what Clojure has done for Lisp?

#16
post #9

While not familiar with Prolog, I understand that Erlang's pattern matching comes from that world - so Erlang? EDIT: Here's a couple references for the Erlang/Prolog connection... http://www.erlang.org/faq/academic.html http://hyperpolyglot.org/logic Also I found this while looking for the reference for the Prolog/Erlang connection... http://www.slideshare.net/adorepump/learning-erlang-from-a-p...

Prolog's unification is quite a bit more powerful than Erlang's pattern matching, though. You can't pass around uninstantiated variables in Erlang. Erlang also discarded backtracking (because it mixes poorly with concurrency).

OTOH, it is possible to add some of it back in. Check out Robert Virding's erlog (http://github.com/rvirding/erlog) and his explanation of how you can add backtracking to erlang (http://rvirding.blogspot.com/2009/03/backtracking-in-erlang-...)

Re: Ask HN: Who/What will do for Prolog what Clojure has done for Lisp?

#17
post #15

Earlier quoted context omitted.

I've also switched to ASP, largely because of choice rules plus filtering. You can write things like: { active(A) } :- thing(A). Which says that for all things A, active(A) is a free choice of true or false, constrained by the requirement to be consistent with all other clauses in the program. That lets you do abductive reasoning, e.g. find an explanation, plan, or cause from a possibility space, consistent with the…

The wikipedia page didn't really shed much light on what ASP is doing under the hood. How does it differ from constraint solvers like http://www.gecode.org/ ? I know that gecode can handle problems like your canvas example well by representing integer variables as sets of intervals. What kind of problems would ASP have the advantage on?

To some extent why you would use each of the declarative-programming paradigms is still an open question imo. Lots of things can be modeled in several, with pros and cons.

I think of ASP as "a semantically nicer Prolog, plus extensions". It originated as one of the attempts to give Prolog's semantics, which are logic-inspired but defined by its procedural goal-chaining algorithm, a clean declarative logical semantics. The "stable model semantics" were one of the competing ones, which became answer-set programming.

It depends on which constraint solver exactly, but two features not present in most pure constraint-solving systems are the Prolog-style deductive reasoning, and negation-as-failure. ASP lets you freely intermingle deductive reasoning chains with constraints, rather than solving things as purely sets of variables with constraints on them (though this is true of other approaches that fall under the "constraint logic programming" heading as well). That lets you do the generate-and-filter style, where you might have a complex deductive logic program generating possibilities, and then effectively a constraint program filtering from them (and the constraint part can sometimes call out to deductive reasoning chains as well, since it's all the same language).

ASP semantics are sort of a superset of Prolog + constraint solvers + abductive reasoners, where you can freely intermingle all those approaches. As a result it isn't, yet anyway, the most efficient reasoner if you fall more squarely into one of those paradigms. Here's an experimental ASP system that also adds efficient constraint variables, though: http://www.cs.uni-potsdam.de/clingcon/

Re: Ask HN: Who/What will do for Prolog what Clojure has done for Lisp?

#20
post #3

Prolog has its limitations, but it still stands out as one of the oldest, influential and important declarative programming languages. IMHO, it's hard to say what is the natural successor to Prolog. For all that it shares with Lisp, it definitely has never shared even a fraction of the popularity. They have two entirely different approaches and purposes though, so this isn't terribly surprising. Even if someone does…

10 or 11 years ago, David Warren was working on an extension called Tabled Logic Programming; his implementation was called XSB. He seems to have abandoned it, which I find disappointing; it looked interesting. In a nutshell, instead of a goal acting like a procedure call as in Prolog, it acts like a coroutine. Here's a link: http://www.cs.sunysb.edu/~warren/xsbbook/book.html

I thought this is being continued as http://xsb.sf.net ?
Post reply on HN