Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Logic programming
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Constraint logic programming=== {{Main|Constraint logic programming}} [[Constraint logic programming]] (CLP) combines Horn clause logic programming with [[constraint solving]]. It extends Horn clauses by allowing some predicates, declared as constraint predicates, to occur as literals in the body of a clause. Constraint predicates are not defined by the facts and rules in the program, but are predefined by some domain-specific model-theoretic structure or theory. Procedurally, subgoals whose predicates are defined by the program are solved by goal-reduction, as in ordinary logic programming, but constraints are simplified and checked for satisfiability by a domain-specific constraint-solver, which implements the semantics of the constraint predicates. An initial problem is solved by reducing it to a satisfiable conjunction of constraints. 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 <code>john's</code> history as a teacher: <syntaxhighlight lang="prolog"> teaches(john, hardware, T) :- 1990 β€ T, T < 1999. teaches(john, software, T) :- 1999 β€ T, T < 2005. teaches(john, logic, T) :- 2005 β€ T, T β€ 2012. rank(john, instructor, T) :- 1990 β€ T, T < 2010. rank(john, professor, T) :- 2010 β€ T, T < 2014. </syntaxhighlight> Here <code>β€</code> and <code><</code> are constraint predicates, with their usual intended semantics. The following goal clause queries the database to find out when <code>john</code> both taught <code>logic</code> and was a <code>professor</code>: <syntaxhighlight lang="prolog"> ?- teaches(john, logic, T), rank(john, professor, T). </syntaxhighlight> The solution <code> 2010 β€ T, T β€ 2012 </code> results from simplifying the constraints <code> 2005 β€ T, T β€ 2012, 2010 β€ T, T < 2014. </code> 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]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)