prolog,successor-arithmetics,non-termination

Your definition of add/3 works fine, and also terminates, if all three arguments are given. If you leave one of them as a variable, one of the goals s2int(XYZ, SXYZ) has then two uninstantiated variables as arguments. It describes thus an infinitely large set, whose complete enumeration takes infinitely long....

prolog,termination,failure-slice,successor-arithmetics

nat_nat_sum(0, B, B). nat_nat_sum(s(A), B, s(C)) :- nat_nat_sum(B, A, C). ?...

prolog,multiplication,successor-arithmetics

thanks @false for the hint to this post: Prolog successor notation yields incomplete result and infinite loop The referenced PDF doc in this post helps clarifying a number of features regarding peano integers and how to get simple arithmetic to work - pages 11 and 12 are particularly interesing: http://ssdi.di.fct.unl.pt/flcp/foundations/0910/files/class_02.pdf...

It helps to understand how Prolog operates when figuring out an existing predicate, or when designing a new one. When you make a query such as: sum( succ(succ(0)), succ(succ(succ(0))), Answer ). Prolog will look for facts and rules matching sum(_, _, _) (sum/3) and select the first one that matches....