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

1.1 Add members to this family. Please pay close attention when adding these mem

ID: 3824131 • Letter: 1

Question

1.1    Add members to this family. Please pay close attention when adding these members, spelling counts and all letters should be lowercase. It may help to construct a family tree for this part. Please indent your additions so that it is easy to identify them.

        

         Add the following males: ed, joshua, and aaron.

         Add the following females: lindsay, allison, and mary.

         Add the following relationship facts:

-       ed is the child of joshua and lindsay.

-       allison is the child of aaron and mary.

-       jennifer and michael are both children of ed and allison.                                                 [5]

For all of the following questions, please label them. For example, if Question 1.0 asks you to define a rule called is_male (X) that returns "yes" (or "true") if X is the father of a member of the family, then your code should look like:

        

/* Question 1.0 */

is_male(X) :-

         male(X);             % “;” is an “or” operation

         father_of(X, _).

1.2    Define (add into the database) a rule called is_female(X) that returns "yes" (or "true") if X is a female or the mother of a member of the family.                                                                                                                                               [4]

         Note: the system will return a "yes", if it finds a "true" answer and there exist no more true answers. The system will return "true ?" if it finds a "true" answer and there are still possibly further matches. In this case, if you type "enter", it will return "yes" and stop. If you type ";", it will continue to search for further answers.

1.3    Define a rule called grandmother_of(X, Z) that returns “yes” (or “true”) if X is a grandmother of Z. Define another rule called grandfather_of(X, Z) that returns “yes” (or “true”) if X is a grandfather of Z.                                                    [4]

1.4    Define a rule called sibling_of(X, Y) that returns “yes” (or “true”) if X is a sibling of Y.    [4]

1.5    Define a rule called parent_of(X, Y) that returns “yes” (or “true”) if X is a parent of Y.      [4]

1.6       Define a rule called descendent_of(X, Y) that returns “yes” (or “true”) if X is a descendent of Y. Note: you will need to use recursion as well as the rule defined above.        [4]

Explanation / Answer

Solution:

male(ed, Joshua, aaron).

female(lindsay,allison,mary).

parent(Joshua,ed).

parent(Lindsay,ed).

parent(aaron,allison).

parent(mary,allison).

parent(ed,jenifer).

parent(ed,michael).

parent(allsion,jenifer).

parent(allison,michael).

Rules:

mother_of(X,Y):- female(X), parent(X,Y).

father_of(X,Y):- male(X),parent(X,Y).

Qs1.0:

is_male(X) :-      male(X); father_of(X, Somebody).

Qs1.2:

is_female(X):-   female(X); mother_of(X,Somebody).

Qs1.3:

grandmother_of(X, Z):-                female(X),mother(X,Y),parent(Y,Z).

grandfather_of(X,Z):-    male(X),father_of(X,Y),parent(Y,Z).

Qs1.4:

sibling_of(X, Y):-               parent(Z,X), parent(Z,Y), X = Y.

Qs1.5:

parent_of(X, Y):-              mother_of(X,Y);father_of(X,Y).

Qs1.6:

descendent_of(X, Y):-   grandfather_of(Y,X);grandmother_of(Y,X).

Hope this helps you. Thank you.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote