This is supposed to recursively define a function sum(X,Y,Z) meaning X + Y = Z. how could anything be simpler, right? Code (Text): sum(0,Y,Y). sum(s(X),Y,s(Z)) :- sum(X,Y,Z). It's very good at telling that 0+1=1 or 0+2=2, etc. But give it anything other than 0 for the first variable and it's lost. What's wrong?