Family wu-kan

About Cousin and Removed

What Is a First Cousin, Twice Removed

If someone walked up to you and said, “Howdy, I’m your third cousin, twice removed,” would you have any idea what they meant? Most people have a good understanding of basic relationship words such as “mother,” “father,” “aunt,” “uncle,” “brother,” and “sister.” But what about the relationship terms that we don’t use in everyday speech? Terms like “second cousin” and “first cousin, once removed”? We don’t tend to speak about our relationships in such exact terms (“cousin” seems good enough when you are introducing one person to another), so most of us aren’t familiar with what these words mean.

Relationship Terms

Sometimes, especially when working on your family history, it’s handy to know how to describe your family relationships more exactly. The definitions below should help you out.

Cousin (a.k.a “first cousin”)

Your first cousins are the people in your family who have two of the same grandparents as you. In other words, they are the children of your aunts and uncles.

Second Cousin

Your second cousins are the people in your family who have the same great-grandparents as you., but not the same grandparents.

Third, Fourth, and Fifth Cousins

Your third cousins have the same great great grandparents, fourth cousins have the same great-great-great-grandparents, and so on.

Removed

When the word “removed” is used to describe a relationship, it indicates that the two people are from different generations. You and your first cousins are in the same generation (two generations younger than your grandparents), so the word “removed” is not used to describe your relationship.

The words “once removed” mean that there is a difference of one generation. For example, your mother’s first cousin is your first cousin, once removed. This is because your mother’s first cousin is one generation younger than your grandparents and you are two generations younger than your grandparents. This one-generation difference equals “once removed.”

Twice removed means that there is a two-generation difference. You are two generations younger than a first cousin of your grandmother, so you and your grandmother’s first cousin are first cousins, twice removed.

Problem Description

Please fulfill the following tasks by using Prolog:

  1. Write sentences describing the predicates Grandchild, Greatgrandparent, Ancestor, Brother, Sister, Daughter, Son, FirstCousin, BrotherInLaw, SisterInLaw, Aunt, and Uncle. Hint: you can define these predicates by choosing child, sibling, male, female, father, mother, and so on.
  2. Find out the proper definition of $m$ th cousin $n$ times removed, in other words, define the predicate mthCousinNremoved(X,Y,M,N). **Hint: You’d better define the predicate distance(X,Y,N) by recursion.
  3. Write down the basic facts depicted in the family tree in Figure \ref{fig:family**.
  4. Ask it who are Elizabeth’s grandchildren, Diana’s brothers-in-law, Zara’s great-grandparents, and Eugenie’s ancestors.

Codes

male(george).
male(kydd).
male(charles).
male(mark).
male(philip).
male(andrew).
male(edward).
male(william).
male(peter).
male(james).

female(mum).
female(elizabeth).
female(spencer).
female(margaret).
female(diana).
female(anne).
female(sarah).
female(sophie).
female(zara).
female(beatrice).
female(eugenie).
female(louise).

spouse(george,mum).
spouse(mum,george).
spouse(elizabeth,philip).
spouse(philip,elizabeth).
spouse(spencer,kydd).
spouse(kydd,spencer).
spouse(diana,charles).
spouse(charles,diana).
spouse(anne,mark).
spouse(mark,anne).
spouse(andrew,sarah).
spouse(sarah,andrew).
spouse(edward,sophie).
spouse(sophie,edward).

child(charles,elizabeth).
child(charles,philip).
child(andrew,elizabeth).
child(andrew,philip).
child(edward,elizabeth).
child(edward,philip).
child(william,charles).
child(william,diana).
child(harry,charles).
child(harry,diana).
child(peter,anne).
child(peter,mark).
child(james,edward).
child(james,sophie).

child(margaret,george).
child(margaret,mum).
child(diana,kydd).
child(diana,spencer).
child(elizabeth,george).
child(elizabeth,mum).
child(anne,elizabeth).
child(anne,philip).
child(zara,anne).
child(zara,mark).
child(beatrice,andrew).
child(beatrice,sarah).
child(eugenie,andrew).
child(eugenie,sarah).
child(louise,edward).
child(louise,sophie).

grandchild(X,Y):-child(X,Z),child(Z,Y).
greatgrandparent(X,Y):-grandchild(Y,Z),child(Z,X).
ancestor(A,B):-child(B,A);(child(C,A),ancestor(C,B)).
mthcousinnremoved(X,Y,0,0):- X\=Y,male(Z),child(X,Z),child(Y,Z).
mthcousinnremoved(X,Y,M,0):-child(X,XX),child(Y,YY),mthcousinnremoved(XX,YY,M-1,0).
mthcousinnremoved(X,Y,M,N):-child(X,Z),mthcousinnremoved(Z,Y,M,N-1).
brother(X,Y):-male(X),mthcousinnremoved(X,Y,0,0).
sister(X,Y):-female(X),mthcousinnremoved(X,Y,0,0).
daughter(X,Y):-child(X,Y),female(X).
son(X,Y):-child(X,Y),male(X).
firstcousin(X,Y):-mthcousinnremoved(X,Y,1,0).
brotherinlaw(X,Y):-spouse(Y,Z),brother(X,Z).
sisterinlaw(X,Y):-spouse(Y,Z),sister(X,Z).
aunt(X,Y):-female(X),mthcousinnremoved(X,Y,0,1).
uncle(X,Y):-male(X),mthcousinnremoved(X,Y,0,1).

Results

下为运行结果的消息内容。

?- grandchild(X,elizabeth),write(X),nl,fail.
william
harry
peter
james
zara
beatrice
eugenie
louise
false.

?- brotherinlaw(X,diana),write(X),nl,fail.
andrew
edward
false.

?- greatgrandparent(X,zara),write(X),nl,fail.
george
mum
false.

?- ancestor(X,eugenie),write(X),nl,fail.
andrew
sarah
elizabeth
philip
george
mum
false.