Cs344 Lect16 Prolog 12feb08
Cs344 Lect16 Prolog 12feb08
Intelligence
Pushpak Bhattacharyya
CSE Dept.,
IIT Bombay
likes(mary,X),likes(john,X)
likes(mary,food)
likes(mary,tea)
likes(john,tea)
likes(john,mary)
likes(mary,food)
likes(mary,tea)
likes(john,tea)
likes(john,mary)
likes(mary,X),likes(john,X)
likes(mary,food)
likes(mary,tea)
likes(john,tea)
likes(john,mary)
likes(mary,X),likes(john,X)
likes(mary,food)
likes(mary,tea)
likes(john,tea)
likes(john,mary)
X is a sister of Y is
X is a female and
X and Y have same parents
Question Answering in
presence of rules
Facts
male (ram).
male (shyam).
female (sita).
female (gita).
parents (shyam, gita, ram).
parents (sita, gita, ram).
Question Answering: Y/N type: is sita
the sister of shyam?
?- sister_of (sita, shyam)
parents(sita,M,F) parents(shyam,M,F)
female(sita)
parents(shyam,gita,ram)
parents(sita,gita,ram)
success
Question Answering: wh-type: whose
sister is sita?
?- ?- sister_of (sita, X)
parents(sita,M,F) parents(Y,M,F)
female(sita)
parents(Y,gita,ram)
parents(sita,gita,ram)
parents(shyam,gita,ram)
Success
Y=shyam
Exercise
1. From the above it is possible for
somebody to be her own sister.
How can this be prevented?
Prolog Program Flow,
BackTracking and Cut
DO NOT BACKTRACK