Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Logic programming
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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]].
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Logic programming
(section)
Add topic