capital(london, england). brother(fred, jane). |
Head :- Body.where Head is a structure (or atom) and Body is a Goal, possibly with conjunctions and disjunctions like in the queries discussed above. The following is a clause
uncle(X,Z) :- brother(X,Y), parent(Y,Z). |
uncle(X,Z) ←— brother(X,Y) ∧ parent(Y,Z)or, more precisely
∀ X ∀ Z: uncle(X,Z) ←— ∃ Y: brother(X,Y) ∧ parent(Y,Z)stating that uncle(X,Z) is true if brother(X,Y) and parent(Y,Z) are true. Note that a fact is equivalent to a clause where the body is true:
brother(fred, jane) :- true. |
parent(abe, homer). parent(abe, herbert). parent(homer, bart). parent(marge, bart). |
ancestor(X,Y) :- parent(X,Y). ancestor(X,Y) :- parent(Z,Y), ancestor(X,Z). |