Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!purdue!lerc.nasa.gov!magnus.acs.ohio-state.edu!math.ohio-state.edu!jussieu.fr!oleane!tank.news.pipex.net!pipex!newsfeed.internetmci.com!news.mel.aone.net.au!inferno.mpx.com.au!news.unimelb.EDU.AU!cs.mu.OZ.AU!lee
From: lee@cs.mu.OZ.AU (Lee Naish)
Subject: Re: Question on strange behavior
Message-ID: <9524019.21509@mulga.cs.mu.OZ.AU>
Originator: lee@munta.cs.mu.OZ.AU
Sender: news@cs.mu.OZ.AU (CS-Usenet)
Reply-To: lee@cs.mu.OZ.AU (Lee Naish)
Organization: Computer Science, University Of Melbourne, Australia
References:  <4164k5$f8d@gap.cco.caltech.edu>
Date: Mon, 28 Aug 1995 09:00:19 GMT
Lines: 31


In article <4164k5$f8d@gap.cco.caltech.edu>, cilibrar@gluttony.ugcs.caltech.edu (Rudi Cilibrasi) writes:
> I've just started learning Prolog.  It seems a very interesting language,
> but there is one part I just don't understand.  Given the following
> program:
> 
> rsucc(zero,one).
> rsucc(one,two). ...
  
> rplus(A,B,Result) :-
>         A = zero,
>         B = Result.
> rplus(A,B,Result) :-
>         A \= zero,
>         rsucc(Adown, A),
>         rsucc(Resultdown, Result),
>         rplus(Adown,B,Resultdown).
> 
> I submit the following queries:

> 4 ?- rplus(X,three,five).
> 
> No
> 

> How come it didn't answer "X = two"?


Negation in most Prolog systems is somewhat limited.  A \= zero generally only behaves sensibly when A is instantiated.  In query 4 it is not.  Some Prolog systems (eg, NU-Prolog) have better facilities for negation which behave more logically.  If you replace A \= zero by A ~= zero then the program works under NU-Prolog.

	lee
