Solutions will be unified with a copy of Template where the variables are replaced with their minimized values. Typically, the Template will contain all or a subset of Goal's variables.
minimize/2 can be written in terms of minimize/4 as follows:
minimize(Goal, Cost) :- minimize(Goal, Goal, Goal, Cost).
% Find the minimal C and bind X to the corresponding value [eclipse]: X::1..3, C #= 3-X, minimize(indomain(X), X, X, C). Found a solution with cost 2 Found a solution with cost 1 Found a solution with cost 0 X = 3 C = 0 yes. % Find the minimal C and don't bind anything [eclipse]: X::1..3, C #= 3-X, minimize(indomain(X), [], [], C). Found a solution with cost 2 Found a solution with cost 1 Found a solution with cost 0 X = X{[1..3]} C = C{[0..2]} Delayed goals: -3 + X{[1..3]} + C{[0..2]}#=0 yes. % Find the minimal C and return it in MinC. Don't bind X or C. [eclipse]: X::1..3, C #= 3-X, minimize(indomain(X), C, MinC, C). Found a solution with cost 2 Found a solution with cost 1 Found a solution with cost 0 X = X{[1..3]} MinC = 0 C = C{[0..2]} Delayed goals: -3 + X{[1..3]} + C{[0..2]}#=0 yes.