Subject: Re: Help

From: Steffen Moeller <[email-masked]>
Date: Tue, 15 Jun 1999 21:06:06 +0100 (BST)

> 
> I try to write a simple program to define a plus by myself. 
> 
> sum(X,0,X).
> sum(W, f(Y), f(Z)):-sum(W,Y,Z).
> 
> This doesnot work and just keep telling me to refine sum.
> Please tell me the reason.

sum(X,0,X).
sum(0,X,X).
sum(f(X),Y,f(Z)):-sum(X,Y,Z).
sum(X,f(Y),f(Z)):-sum(X,Y,Z).

Seems to work.

?- sum(f(0),f(0),f(f(0))).

Yes
?- sum(f(0),X,f(f(0))).

X = f(0)

Yes
?- sum(0,f(0),f(f(0))).

No
?- sum(X,f(0),f(f(f(f(0))))).

X = f(f(f(0))) ;