6

  • Write a Prolog predicate, minus1(X,Y), which is true if X is the successor of Y, i.e. if X = Y+1, or Y=X-1. Naturally, this predicate will fail if X is 0.
    ?- minus1(s(s(0)), Y).
    Y = s(0)
    ?- minus1(0, Y).
    false. 
    

    Answer:

    minus1(s(X), X).