Family tree — Probably the most common first example of a logic program is that involving a family tree. Give the following family tree (see attached screenshot) a) Build a knowledge base using the predicate parent/2, which encodes a person is the parent (biological, not by marriage) of another person; male/1, which encodes a person is a male; and female/1, which encodes a person is a female. b) Add the following rules to the knowledge base: i. mother(X, Y), which means X is Y’s mother. father(X, Y), which means X is Y’s father . grandfather(X, Y), which means X is Y’s grandfather. (Note: Y can have two grandfathers: one on the maternal side, the other on the paternal side.) grandmother(X, Y), which means X is Y’s grandmother. (Note: Y can have two grandfathers: one on the maternal side, the other on the paternal side.) v. siblings(X,Y). which means X and Y are siblings. vi. You may add aunt, uncle and cousin. c) Test your implementation by asking queries. Write down your query and also the result. i. Who are the siblings of Lisa? ii. List all the grandparents of Lisa? iii. List all family members? (Note: Same type of facts and rules should be grouped together, otherwise, you will get discontiguous error and clauses will be ignored.)
Family tree — Probably the most common first example of a logic program is that involving a family tree. Give the following family tree (see attached screenshot)
a) Build a knowledge base using the predicate parent/2, which encodes a person is the parent (biological, not by marriage) of another person; male/1, which encodes a person is a male; and female/1, which encodes a person is a female.
b) Add the following rules to the knowledge base:- i. mother(X, Y), which means X is Y’s mother.
-
father(X, Y), which means X is Y’s father .
-
grandfather(X, Y), which means X is Y’s grandfather. (Note: Y can have two
grandfathers: one on the maternal side, the other on the paternal side.)
-
grandmother(X, Y), which means X is Y’s grandmother. (Note: Y can have two
grandfathers: one on the maternal side, the other on the paternal side.)
- v. siblings(X,Y). which means X and Y are siblings.
- vi. You may add aunt, uncle and cousin.
c) Test your implementation by asking queries. Write down your query and also the result.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images