:- module(_,_).

% Recovering some reversibility for the ISO-Prolog is/2 
% built-in 

plus(X,Y,Z) :- Z is X + Y.

% Try:
% ?- plus(4,5,Z).
% Works, but cannot 'run backwards':  
% ?- plus(X,5,9).

% To recover some reversibility: 

plus2(X,Y,Z) :- number(X),number(Y), Z is X + Y.
plus2(X,Y,Z) :- number(X),number(Z), Y is Z - X.
plus2(X,Y,Z) :- number(Y),number(Z), X is Z - Y.

% Try:
% ?- plus2(4,5,Z).
% ?- plus2(X,5,9).
% But, it cannot do: 
% ?- plus2(X,Y,9).

% In fact, this should raise an error, rather than simply 
% failing (we will see solutions for this later).

% A much better solution: the addition of constraints to 
% the language: Constraint Logic Programming (CLP) 
% --see later!
