2024 Ai 05
2024 Ai 05
parent(tom, bob).
• Notes
• The names of all relationships and objects must begin
with a lower-case letter.
• The relationship is written first, and the objects are
separated by commas, and the objects are enclosed
by a pair of round brackets.
• A full stop "." must come at the end of a fact.
jim
A family tree.
Artificial Intelligence (5) 9
Questions about facts
• The special symbol is written as a question mark followed by a
hyphen.
• The question "Is Bob a parent of Pat?" can be written in Prolog as:
?- parent(bob, pat).
true.
?- parent(liz, pat).
false.
A family tree.
Artificial Intelligence (5) 17
Question 5-1
• Assuming the parent relation as defined in the previous slide,
what will be Prolog's answers to the following questions?
head body
(a conclusion part) (a condition part)
?- mother(pam, bob).
true .
bob liz
X = pam and Y = bob.
mother(pam, bob) :- parent(pam, bob), female(pam).
Z
sister(X, Y) :- Z
parent(Z, X), parent(Z, Y), female(X).
parent parent
For all X and Y,
X is a sister of Y if female
(1) both X and Y have the same parent, and X Y
(2) X is a female. sister
?- sister(X, pat).
X = ann;
bob liz X = pat.
jim
A family tree.
Artificial Intelligence (5) 26
Question 5-2
1. Define the relation "grandchild"
using the "parent" relation. Hint: It
will be similar to the grand parent
relation.
2. Define the relation aunt(X, Y) in
terms of the relations "parent" and
"sister".