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

Prolog Transcribe the above diagram into father and mother relationships as Prol

ID: 3775195 • Letter: P

Question

Prolog

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.]

Lisa Abe Nancy John Mary Jill Kim Rick Figure 1: Family Tree Tony Bill Sarah Rob Susan Phil Ann Jack Jim martha

Explanation / Answer

parent(X,Y):-mother(X,Y).%is true if X is a parent of Y parent(X,Y):-father(X,Y).%is true is x is a parent of Y same_generation(X,Y):-parent(X,Y). % is true is X is a descendent of Y same_generation(X,Y):-parent(X,Z),same_generation(Z,Y).%is true X isa descendentof Y mother(lisa,abe). mother(lisa,sarah). mother(sarah,susan). mother(susan,jack). mother(susan,phil). mother(mary,jill). mother(jill,rick). mother(nancy,john). father(rob,jack). father(rob,phil). father(phil,ann). father(jack,kim). father(jack,jim). father(jim,martha). father(abe,john). father(john,jill). father(bill,susan). father(tony,abe). father(tony,sarah).