Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!uunet!munnari.oz.au!lee From: lee@munnari.oz.au (Lee Naish) Newsgroups: comp.lang.prolog Subject: Re: Delayed Inequality Predicate Message-ID: <6565@munnari.oz.au> Date: 30 Jan 91 06:30:15 GMT References: <9101260626.AA06894@ucbvax.Berkeley.EDU> Sender: news@cs.mu.oz.au Reply-To: lee@munmurra.UUCP (Lee Naish) Organization: Comp Sci, University of Melbourne Lines: 45 In article <9101260626.AA06894@ucbvax.Berkeley.EDU> ludemann@mlpvm1.iinus1.ibm.com writes: >takahash@rex.cs.tulane.edu (Silvia Takahashi) asks: > >> I am looking for a Prolog that implements the inequality >> predicate using delayed evaluation. ... > >As you mentioned, MU-Prolog and IC-Prolog have this. Others >include: the NU-Prolog (MU-Prolog's successor), Prolog-II >Prolog-III, Prolog/MALI, and IBM-Prolog Also Sepia and Sicstus. One difference between systems is whether quantifiers are supported. Reasonably often I want to express things such as X is not a cons cell; in other words, for all H and T, X is not equal to H.T. This can be expressed in NU-Prolog as follows: all [H,T] X ~= H.T The implementation limits the scopes of H and T to this call and they are allowed to be instantated by the unification with X. The original dif/2 prediate from Prolog-II (and adopted in several systems) cannot express this (you can do it by using functor; other more complex cases need disjunction also). It is also often desirable to check for equality and return true or false, rather than fail or succeed (dif and ~= are not flexible enough for this). It can be done in NU-Prolog by using termCompare/3 (like compare/3, but it delays until the terms are sufficiently instantiated). If-then-else is also treaded specially in NU-Prolog if the condition is a call to =/2 (possibly with quantifiers). One final thing which is sometimes nice (but non-logical) is to treat variables as being quantified (so they are allowed to be instantated by the unification), without limiting their scope. This can be done in NU-Prolog by using gAll instead of all. One use is meta interpreters: solve((all Vars T1 ~= T2)) :- gAll Vars T1 ~= T2. ... Here all variables in Vars are treated as being quantified and the scope of Vars is the whole clause. There is a paper in the London ICLP, LNCS 225, (1986) discussing the negation facilities of NU-Prolog. lee