Information Technology Reference
In-Depth Information
2.2.1 Definitions of logic programming
Firstly we introduce the Horn clause which is the constituent of logic programs.
A clause consists of two parts: the head and the body. As an IF-THEN rule,
the condition portion of a clause is called the head and the conclusion portion of
it is called the body.
Definition 2.1 A Horn clause is a clause that contains at most one literal
(proposition / predicate) at the head.
Horn clauses in Prolog can be separated into three groups:
(1) Clauses without conditions (facts): A.
(2) Clauses with conditions (rules): A :- B 1 , …, B n .
(3) Goal clauses (queries): ? :- B 1 ,…,B n .
Semantics of above Horn clauses is informally described as follows:
(1) The clause A states that A is true for any assignments on variables.
(2) The clause A :- B 1 ,…,B n states that for any assignments on variables: if B 1 ,…,
and B n are evaluated to be true, then A must also be true.
(3) The goal clause ? :- B 1 ,…,B n represents a query that will be executed.
Execution of a Prolog program is initiated by the user's posting of a query;
the Prolog engine tries to find a resolution refutation of the negated query.
For example, here are two Horn clauses:
a) W(X,Y) :- P(X), Q(Y).
b) ?-R(X,Y),Q(Y).
Search WWH ::




Custom Search