Page 204 - DCAP506_ARTIFICIAL_INTELLIGENCE
P. 204
Artificial Intelligence
Notes The if and then parts of a rule are separated by the: symbol, referred to as the infix operator. The
conditional part of the rule is written on the right of the infix operator and conclusion part on its
left. A rule can be declared with a condition. For example, you can declare that if the weather is
sunny, the day is to be selected for a picnic. The ProLog statement for declaring this rule and its
condition is:
picnic(day) :- weather(day,sunny).
14.2.3 Conversion from English to Prolog Facts and Rules
The following program includes a number of predicates that portray a family’s genealogical
relations.
female(amy).
female(merry).
male(john).
male(bruce).
male(ogden).
parentof(amy,merry).
parentof(amy,john).
parentof(amy,bruce).
parentof(ogden,merry).
parentof(ogden,john).
parentof(ogden,bruce).
The above program includes the three straightforward predicates: female; male; and parentof.
They are parameterized with what are known as ‘atoms.’ There are other family relations which
could also be defined as facts, but this is a deadly process. Presuming customary marriage and
child-bearing practices, we could define some rules which would reduce the tediousness of
determining and listing all the probable family relations.
Example: Suppose you are required to know if merry had any siblings, the first question
you must request is “what does it mean to be a sibling?” To be someone’s sibling you must have
the same parent. This last sentence can be written in Prolog as
siblingof(X,Y) :-
parentof(Z,X),
parentof(Z,Y).
A conversion of the above Prolog rule into English would be “X is the sibling of Y given that Z
is a parent of X, and Z is a parent of Y.” X, Y, and Z are variables. This rule though, also defines
a child to be its own sibling. To correct this we must add that X and Y are not similar. The exact
version is:
siblingof(X,Y) :-
198 LOVELY PROFESSIONAL UNIVERSITY