Family Tree Expansion

Review the family tree example from the previous prolog lab.

Enhance your prolog family code to include full definitions of the following:

Test your code with the following questions. First, determine what the answer should be by consulting the family tree chart; then convert the questions into the appropriate form for a Prolog query; then finally test your query within Prolog (having consulted both windsorfacts.pl and your family rule file).

  1. Who is Edward married to?
  2. Who is married to Edward? (Note, the query should be different, even though the answer should be the same.)
  3. Is Edward the brother of Andrew?
  4. Is Andrew the brother of Edward?
  5. Is Andrew the brother of Andrew?
  6. Is Edward the brother of Anne?
  7. Is Anne the brother of Edward?
  8. Is Anne the sister of Andrew?
  9. Does Margaret have any siblings?
  10. Who are the sons of Diana?
  11. Who are the sons of Charles?
  12. Whose son is Charles?
  13. Is Charles the daughter of anyone?
  14. Who are the uncles of Prince William?
  15. Who has Antony as an uncle?
  16. Who are the nieces & nephews of Margaret?
  17. Who are the nephews of Philip?
  18. Who is Andrew's son?
  19. Who is Alice's son?
  20. Whose daughter is Diana?
  21. Who are the daughters of Elizabeth Bowes-Lyon (lizzie)?
  22. Who are the children of Queen Elizabeth?
  23. Does Henry (harry) have any sons or daughters?
  24. Who are the cousins of Edward?
  25. Who are the cousins of Anne?
  26. Who are the grandfathers of Henry?
  27. Who are the granddaughters of George?
  28. Who are the grandsons of George?
  29. Is anyone married to one of George's grandchildren?


Challenge (not required)

Further enhance your code by providing definitions for the following (note that you will need to use recursion for these -- be careful to avoid infinite looping!)

Test with the following:

  1. Is Lizzie an ancestor of David?
  2. Is Lizzie an ancestor of Charles?
  3. Is Lizzie an ancestor of Sarah?
  4. Is Andrew a descendant of Alice?
  5. Is David a descendant of Antony?
  6. Is Anne an ancestor of herself?
  7. Is David a descendant of Lizzie?
  8. Who are the ancestors of Anne?
  9. Who are the ancestors of Margaret?
  10. Who are the ancestors of Alice?
  11. Who are the descendants of Philip?
  12. Who are the descendants of Charles?
  13. Who are the descendants of William?
  14. Is Elizabeth Bowes-Lyon (lizzie) a blood relative of Prince Henry (harry)?
  15. Is she a blood-relative of Diana?
  16. Who are the blood relatives of Diana?
  17. Who are the blood relatives of Charles?
  18. Is Alice a relative of Elizabeth?
  19. Is Alice a relative of Lizzie?
  20. Who has a nephew that is married?
  21. Who has a nephew that is married to somebody's aunt?
  22. What uncle is married to someone's cousin?
  23. Who is married to the cousin of someone with children?
Copyright © 1999-2010| Gene Rohrbaugh | Privacy Statement