Family relationships
Use the predicates male/1
, female/1
,
and parent_of/2
to represent the following family
tree as a Prolog knowledge base.
Solution
Now, formulate rules to capture the following relationships:
father_of(Father,Child)
andmother_of(Mother,Child)
grandfather_of(Grandfather,Child)
andgrandmother_of(Grandmother,Child)
sister_of(Sister,Person)
aunt_of(Aunt,Person)
anduncle_of(Uncle,Person)
To test your knowledge base ask all kinds of queries. For example,
- Does Harry have an aunt? Who?
- Who are the grandparents of Harry?
- Who are the grandchildren of Paul and Helen?
- Does James have a sister?
- ...