Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

FYI, I\'m happy to offer MORE POINTS if needed, chegg only allowed me to offer 1

ID: 3569308 • Letter: F

Question

FYI, I'm happy to offer MORE POINTS if needed, chegg only allowed me to offer 1500 points so if you'd like more points to answer it please let me know how to offer or give more.

Thanks in advance for any help, this is the only one I'm having trouble with!

Transcribe the above diagram into father and mother relationships as Prolog facts. Write a predicate called same_generation(X, Y) which succeeds if individuals X and Y are siblings/cousins of the same generation (i.e., they are descendants of a common person and both are same number of links down from the common predecessor). You can ignore the double arrows as they depict the relationship `married' that you may not

need for this problem. [HINT: Use `parent' relation to implement `same generation'. Two persons are of the same generation if they have a common parent or if their parents are of the same generation.]

Explanation / Answer

First write all the facts i.e )

mother(Lisa,Abe).

father(Tony,Abe).

mother(Lisa,Sarah).

..... and so on

then for implementing "samegeneration" the following rules will do

parent(X, Y) :- father(X, Y).
parent(X, Y) :- mother(X, Y).

sibling(X,Y) :- father(P,X), father(P,Y), mother(Q,X), mother(Q,Y).

ancestor(X, Y) :- parent(X,Y); parent(X,Z), ancestor(Z,Y).

samegeneration(X,Y) :- ancestor(Someone,X), ancestor(P,Y), sibling(Someone,P).