/* naive arithmetics */ add(0,Y,Y). add(s(X),Y,s(Z)) :- add(X,Y,Z). multiply(0,_,0). multiply(s(X),Y,Z) :- multiply(X,Y,Z0), add(Z0,Y,Z).