2

I am looking resources for learning resolving of constraints in Prolog. For example,

List=[X, Y, Z], List ins 1..4, X - Y #= Z. 
1
  • 1
    This is incorrect Prolog syntax. List[X, Y, Z] is invalid as was commented on in your previously posted problem. Commented Apr 19, 2014 at 19:15

1 Answer 1

3

What I understand, your want to get concrete solutions (and not the domains). For this, use label/1 or labeling/2, which will give all the explicit solutions (via backtracking). In SWI-Prolog, these predicates are documented here: labeling/2 .

label(List) is equivalent to labeling([],List).

For this simple example, label(List) would suffice:

?- List=[X, Y, Z], List ins 1..4, X - Y #= Z,label(List).

In general, you would benefit by reading the full documentation of clpfd (here for SWI-Prolog).

Sign up to request clarification or add additional context in comments.

2 Comments

I am trying to figure out how Prolog work out the domains. Could you recommend some source to read more on it?
If you want a general descriptions how domains (as well as propagators etc) works, a full book on Constraint (Logic) Programming is probably best for describing this is some detail. Some books I like on this: Rina Dechter: "Constraint Processing" (2003), Apt "Principles of Constraint Programming" (2003), Marriott & Stuckey "Programming with Constraints" (1998, a little old but still inspiring).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.