ack(0, N, N+1). ack(M, 0, R) :- { M >= 1 }, ack(M-1, 1, R). ack(M, N, R) :- { M >= 1, N >= 1 }, ack(M, N-1, T), ack(M-1, T, R).