Constraint logic programming: Difference between revisions

Content deleted Content added
substitution of variables + types of constraints + book
m X->Y (the example makes more sense this way)
Line 1:
'''Constraint logic programming''' is a variant of [[logic programming]] that incorporates constraints as used in [[constraint satisfaction]]. A constraint logic program is a logic program that includes constraints in the body of clauses.
 
An example of a clause including a constraint is <code>A(X,Y) :- X+Y>0, B(X), C(XY)</code>. In this clause, <code>X+Y>0</code> is a constraint; <code>A(X,Y)</code>, <code>B(X)</code>, and <code>C(XY)</code> are literals like in regular logic programming. A clause can be used to prove the goal if its constraints are satisfied and its literals can be proved. More precisely, the set of all constraints of clauses used in a derivation is supposed to be satisfiable in order for the derivation to be valid.
 
When the interpreter scans the body of a clause, it [[Backtracking|backtrack]]s if a constraint is not satisfied or a literal cannot be proved. There is a difference in how constrains and literals are handled: literals are proved by recursively evaluating other clauses; constraints are placed them in a set called ''constraint store''. This constraint store contains all constraints assumed satisfiable during execution. Evaluating a literal may also involve adding constraints to the constraint store.