General
Material
Lecture 1
Lecture 2
Lecture 3
Lecture 4
Lecture 5

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) and mother_of(Mother,Child)
  • grandfather_of(Grandfather,Child) and grandmother_of(Grandmother,Child)
  • sister_of(Sister,Person)
  • aunt_of(Aunt,Person) and uncle_of(Uncle,Person)
Hint

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?
  • ...

Back to the practical session of day 1.