Question: To exit from GNU Prolog, type your end-of-file character at the main Prolog prompt ^d (Ctrl-d). | ?- ^d You can find a complete set

 To exit from GNU Prolog, type your end-of-file character at the

To exit from GNU Prolog, type your end-of-file character at the main Prolog prompt ^d (Ctrl-d).

 | ?- ^d 

You can find a complete set of GNU Prolog commands at http://www.gprolog.org/manual/gprolog.html.

Now, you can start to add your code into the program.

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]

You are given the following Prolog (fact/rule) database. 125 points Database for family It consists of facts and rules. Facts male (michael). male (thomas). female (Jennifer). female (lisa). father of (mark, beth) mark is the father of beth mother of (jen, tom). en is the mother of tom Rules is male (X male (X) father of (X Enter the program using a text editor such as vi or nano under Unix operation system and save the file as family.pl. You may enter the program on your own computer and upload the program into your cse240prolog directory in general server. Compile the program using the Prolog command: gplc family.pl Then, enter GNU Prolog programming environment by executing the Unix command gprolog Execute the program family by typing GNU Prolog command family Ask questions by typing, e.g.: ntroduction to Programming Languages 2 l P a g e CSE240 Homework 13 I?- father of (michael lisa mother of (lisa thomas To exit from GNU Prolog, type your end-of-file character at the main Prolog prompt d (Ctrl-d). nd You are given the following Prolog (fact/rule) database. 125 points Database for family It consists of facts and rules. Facts male (michael). male (thomas). female (Jennifer). female (lisa). father of (mark, beth) mark is the father of beth mother of (jen, tom). en is the mother of tom Rules is male (X male (X) father of (X Enter the program using a text editor such as vi or nano under Unix operation system and save the file as family.pl. You may enter the program on your own computer and upload the program into your cse240prolog directory in general server. Compile the program using the Prolog command: gplc family.pl Then, enter GNU Prolog programming environment by executing the Unix command gprolog Execute the program family by typing GNU Prolog command family Ask questions by typing, e.g.: ntroduction to Programming Languages 2 l P a g e CSE240 Homework 13 I?- father of (michael lisa mother of (lisa thomas To exit from GNU Prolog, type your end-of-file character at the main Prolog prompt d (Ctrl-d). nd

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!