Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!uunet!in1.uu.net!allegra!alice!pereira
From: pereira@alta.research.att.com (Fernando Pereira)
Subject: Re: SWI prolog DCG expansion bug report
In-Reply-To: jensk@bbn.hp.com's message of 25 Jul 1995 13:58:07 GMT
X-Nntp-Posting-Host: alta.research.att.com
Message-ID: <PEREIRA.95Jul25232224@alta.research.att.com>
Sender: usenet@research.att.com (netnews <9149-80593> 0112740)
Reply-To: pereira@research.att.com
Organization: AT&T Bell Laboratories
References: <3v1ugu$l9i@cdn_mail.telecom.com.au> <3v2t9f$l9s@hpscit.sc.hp.com>
Date: Wed, 26 Jul 1995 03:22:24 GMT
Lines: 44

In article <3v2t9f$l9s@hpscit.sc.hp.com> jensk@bbn.hp.com (Jens Kilian) writes:
   Keith Whitwell (xv02434@codac.codac.telecom.com.au) wrote:
   > pred(P, C) -->
   > 	({ P == C } ->
   > 	     { C = [] }
   > 	;    { P = [] }).

   [...]

   > pred(A, B, C, D) :-
   >         (   (   A == B
   >             ->  B = []
   >             ),
   >             D = C
   >         ;   A = [],
   >             D = C
   >         ).

   [...]

   > ... this is incorrect.

   I don't see anything unusual here.  What translation would you expect?

The parentheses around "A == B -> B = []" should not be there. The
correct translation (Quintus Prolog 3.1.1) is:

p(A,B,C,D) :- 
        (   A==B ->
            B=[],
            D=C
        ;   A=[],
            D=C
        ).

The problem in the incorrect translation is that the second argument
of -> is just "B = []" rather than the correct "B = [], C = D".
--
Fernando Pereira
2B-441, AT&T Bell Laboratories
600 Mountain Ave, Murray Hill, NJ 07974-0636
pereira@research.att.com


