Page 1 of 1

This is to explore running Prolog. We have family information as follows. For example, louis-mary represents louis is a

Posted: Mon May 02, 2022 12:01 pm
by answerhappygod
This is to explore running Prolog. We have family information as
follows. For example, louis-mary represents louis is a parent of
mary.
louis-mary, louis-mike, mary-neon, mary-nick, neon-opera,
nick-oliver, opera-peter, opera-pam,
queen-rose, queen-robert, rose-susan, rose-smith, smith-tim
(1). Write the above facts as follows and save it as
yourlastname.pl. If your last name is Adam, then save it as
adam.pl.
parent(louis, mary).

parent(smith, tim).
Add female to mary, queen, rose, susan, opera, and pam. For
example, female(mary). Add male to all remaining members. For
example, male(louis). Susan is Nick’s wife. Add wife(susan,
nick).
(2) In yourlastname.pl file, write and add the following rules.
Test them as requested.
1. ancestor(X,Y) : X is an ancestor of Y
o test ancestor(mary, Y). Submit all generated result for Y by
running your program.
2. descendant(X,Y): X is a descendent of Y. Do not use “ancestor”
here.
o test descendant(peter, Y). Submit all generated result for Y by
running your program.
3. motherinlaw(X,Y): X is a mother-in-law of Y
o test motherinlaw(X,Y). Submit all generated result for X and Y by
running your program.
4. brother(X,Y) : X is a brothr of Y
o test brother(X,Y). Submit all generated result for X and Y by
running your program.
5. niece(X,Y) : X is a niece of Y
o test niece(X,Y). Submit all generated result for X and Y by
running your program.
If you need an operation not, use the operator “not” ( \== ), like
X\==Y.
If you want, you can make your own rules and use them. For example,
“grandparent(X, Y) :- parent(X, Y),
parent(Y, Z)”. But, you can’t make your own facts and add them to
the prolog file. For example, “grandparent(louis, neon)” is not
allowed.
You should submit the followings to have full score:
(1) your program file
(2) your printed prolog list (your pdf list of the program)
(3) the output printed by running your program (to show your
result). Screenshots are accepted.