🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1737

Delayed Inequality Predicate

#1737
From: "Peter Ludemann"
Date: Sat, 26 Jan 1991 05:50
37 lines
1996 bytes
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 (apologies for those
I have missed).

IBM-Prolog provides delayed inequality and "not"; it also provides
a general delay mechanism.  For example, when writing
coroutining predicates, it is often handy to merge two streams
(that is, lists which may not yet be fully instantiated),
delaying until at least one of the streams has its head
instantiated.  For example, we want to handle:

   <- merge(A, B, C) & A = [a|X] & B = [c,d] & X = [b] .

The notation "P when (^var(X) | ^var(Y))" means "wait until
either X or Y is instantiated before calling goal P" (other
Prologs call this "freeze" or "geler"); the notation
"p(notvar$X)" in the head of a clause means "succeed only if X
is not a variable" (yes, Richard, I could have used var/1, etc.).

  merge(In1, In2, Out) <- merge2(In1, In2, Out) when (^var(In1) | ^var(In2)) .

  merge2(notvar$ In1,      In2, Out) <- merge3(In1, In2, Out) .
  merge2(var$ In1, notvar$ In2, Out) <- merge3(In2, In1, Out) .

  merge3([],      In2, In2) .
  merge3([I|In1], In2, [I|Out]) <- merge(In1, In2, Out) .

(This program does not run backwards; to handle that, I would need to
change the first "when" to include ^var(In3), and modify merge2/3.)

- Peter Ludemann    ludemann@mlpvm1.iinus1.ibm.com
Technical Details
Message-ID: <9101260626.AA06894@ucbvax.Berkeley.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!usc!ucsd!ucbvax!mlpvm1.iinus1.ibm.com!ludemann

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!usc!ucsd!ucbvax!mlpvm1.iinus1.ibm.com!ludemann
From: ludemann@mlpvm1.iinus1.ibm.com ("Peter Ludemann")
Newsgroups: comp.lang.prolog
Subject: Delayed Inequality Predicate
Message-ID: <9101260626.AA06894@ucbvax.Berkeley.EDU>
Date: 26 Jan 91 05:50:53 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Reply-To: ludemann@mlpvm1.iinus1.ibm.com
Lines: 37