Re: Prolog goals order



On Thu, 24 Aug 2006 15:58:49 -0700, Greg Buchholz wrote:


Mauro DiNuzzo wrote:
As an example, the goal:
?- X+1>10, read(X).
raises an instantiation error. (we have the mind full of examples like
this!)

My question is: "why Prolog does not change itself to overcome this
problem?".

FWIW, I think the Mercury langauge does exactly that. From
http://doc.rz.ifi.lmu.de/programming/mercury/transition_guide.html

"the Mercury compiler automatically reorders conjunctions so that all
consumers of a variable come after the producer"


The Mercury compiler reorders goals in a conjunction statically and
within a clause. That's cool, but it is also quite limited.
It relies on your declarations (or what it can infer from your
declarations+program). Dynamic reordering and reordering beyond the
clause scope is what one would really want - or what I guess Mauro would
like. It is possible, but as Jan has pointed out, it comes at a
performance price (especially when you don't need it). There is another
cost: if two (or more) goals are ready to execute at the same time, you
(as a programmer) usually have no control over the order in which they are
executed. This means you might lose control over the complexity of your
program. For programmers, that's unacceptable. For a specification, that
is fine. Maybe some time in the future, computer science bridges the gap
between programming and specifying. Until then, entre les deux notre coeur
se balance: try a bit of Prolog, try a bit of Answer Set Programming. And
tell us about your experience.

Cheers

Bart Demoen
.



Relevant Pages

  • Re: Is Prolog good for AI? (was: Minsky still posting)
    ... > than a programming language suitable for large scale direct human use. ... but it was Prolog nor AI. ... >> than most other languages. ... PHP because it solves a very specific problem. ...
    (comp.lang.prolog)
  • Re: Sublists question
    ... I do not really get what the predicate means or does. ... >>helps just to write the predicate out clearly in natural language, ... >>then translate into Prolog. ... more as a functional programming language than as a logic ...
    (comp.lang.prolog)
  • Re: Real World Applications
    ... Craft of Prolog is pretty old and actually not that good as giude for ... good, large scale programming. ... One reason has been mentioned here before: adding another language comes ... be used efficiently for large scale real time constraint programming ...
    (comp.lang.prolog)
  • Re: Real World Applications
    ... For Prolog `in the wild', that may be true, I see a lot of really ugly ... As long as people follow shared design ... I don't think that is a real issue with the language. ... graduate courses in logic and logic programming. ...
    (comp.lang.prolog)
  • Hear Ye, Hear Ye, Hear Ye...
    ... and Imposium on the First Annual N Queens in Prolog ... Programming Conference and Review. ... The Chair will hear proposals on what to call the ... The Chair will be competing under the Initiate title, ...
    (comp.lang.prolog)