% - Finite domains: some first queries: 

% First, we load the finite domains package:
% ?- use_package(clpfd).

% ?- X #= A + B, A in 1..3, B in  3..7.

% -> The respective minimums and maximums are added
% -> There is no unique solution

% Similarly: 
% ?- X #= A - B, A in 1..3, B in 3..7.

% Putting more constraints results in a unique solution:
% ?- X #= A - B, A in 1..3, B in 3..7, X #>= 0.


% We can use domain/3 to define the (finite) domains of variables.
% ?- domain([X, Y, Z],1,1000), X*X+Y*Y #= Z*Z, X #>= Y.

% Labeling can be used to get the concrete values that correspond
% within those ranges: 
% ?- domain([X, Y, Z],1,1000), X*X+Y*Y #= Z*Z, X #>= Y, labeling([],[X,Y,Z]).

% And minimize/2 can be used to find the values
% that minimize some variable:
% ?- domain([X, Y, Z],1,100), X*X+Y*Y #= Z*Z, X #>= Y, minimize(labeling([],[X,Y,Z]), Y).
