Content deleted Content added
m →Constraint logic programming: <code> |
|||
Line 474:
Interestingly, the first version of Prolog already included a constraint predicate dif(term1, term2), from Philippe Roussel's 1972 PhD thesis, which succeeds if both of its arguments are different terms, but which is delayed if either of the terms contains a variable.<ref name=":02"/>
The following constraint logic program represents a toy temporal database of <
<syntaxhighlight lang="prolog">
teaches(john, hardware, T) :- 1990 ≤ T, T < 1999.
Line 482:
rank(john, professor, T) :- 2010 ≤ T, T < 2014.
</syntaxhighlight>
Here <
<syntaxhighlight lang="prolog">
?- teaches(john, logic, T), rank(john, professor, T).
</syntaxhighlight>
The solution
<
2010 ≤ T, T ≤ 2012
</
results from simplifying the constraints
<
2005 ≤ T, T ≤ 2012, 2010 ≤ T, T < 2014.
</
Constraint logic programming has been used to solve problems in such fields as [[civil engineering]], [[mechanical engineering]], [[digital circuit]] verification, [[automated timetabling]], [[air traffic control]], and finance. It is closely related to [[abductive logic programming]].
|