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:
- married or spouse (note that this relationship is symmetric: if spouse(A,B) is true, then spouse(B,A) is true as well. But be careful to avoid infinite recursion!)
- brother, sister
- son, daughter
- grandmother, grandfather,
- grandson, granddaughter
- aunt, uncle
- niece, nephew
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).
- Who is Edward married to?
- Who is married to Edward? (Note, the query should be different, even though the answer should be the same.)
- Is Edward the brother of Andrew?
- Is Andrew the brother of Edward?
- Is Andrew the brother of Andrew?
- Is Edward the brother of Anne?
- Is Anne the brother of Edward?
- Is Anne the sister of Andrew?
- Does Margaret have any siblings?
- Who are the sons of Diana?
- Who are the sons of Charles?
- Whose son is Charles?
- Is Charles the daughter of anyone?
- Who are the uncles of Prince William?
- Who has Antony as an uncle?
- Who are the nieces & nephews of Margaret?
- Who are the nephews of Philip?
- Who is Andrew's son?
- Who is Alice's son?
- Whose daughter is Diana?
- Who are the daughters of Elizabeth Bowes-Lyon (lizzie)?
- Who are the children of Queen Elizabeth?
- Does Henry (harry) have any sons or daughters?
- Who are the cousins of Edward?
- Who are the cousins of Anne?
- Who are the grandfathers of Henry?
- Who are the granddaughters of George?
- Who are the grandsons of George?
- 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!)
- ancestor (include only direct bloodline, e.g., mother and father, four grandparents, eight great grandparents, etc.)
- descendant (only direct bloodline descendants, e.g., one's children and their children, etc.)
- bloodrelative (what concise definition can be given? in addition to descendants and ancestors, this must also include aunts and uncles, cousins, etc.)
- relative (what relatives are not bloodrelatives? e.g., my sister's husband is my brother-in-law, as is my wife's brother...)
Test with the following:
- Is Lizzie an ancestor of David?
- Is Lizzie an ancestor of Charles?
- Is Lizzie an ancestor of Sarah?
- Is Andrew a descendant of Alice?
- Is David a descendant of Antony?
- Is Anne an ancestor of herself?
- Is David a descendant of Lizzie?
- Who are the ancestors of Anne?
- Who are the ancestors of Margaret?
- Who are the ancestors of Alice?
- Who are the descendants of Philip?
- Who are the descendants of Charles?
- Who are the descendants of William?
- Is Elizabeth Bowes-Lyon (lizzie) a blood relative of Prince Henry (harry)?
- Is she a blood-relative of Diana?
- Who are the blood relatives of Diana?
- Who are the blood relatives of Charles?
- Is Alice a relative of Elizabeth?
- Is Alice a relative of Lizzie?
- Who has a nephew that is married?
- Who has a nephew that is married to somebody's aunt?
- What uncle is married to someone's cousin?
- Who is married to the cousin of someone with children?
