Starting from:

$30

CS4800-Homework 6 Prolog Interpreter Solved

The purpose of this assignment is for you to become familiar with the Prolog interpreter.

1. Define facts to represent your own family, descending from your grandparents. Include your four grandparents, the children of your grandparents, and the children of these children. Include facts for the predicates father, mother, male, and female, as they apply to all of these people. Add comments to the code telling who each family member is in relation to you. 


2. Define the Prolog predicate grandmother(A,B) to mean that A is B's grandmother, and use it to find your own grandmothers. Note that your grandmothers are your mother's mother and your father's mother. For purposes of this exercise, you need only consider biological or adoptive parents and grandparents, not step parents. You may include as many rules as you need to help you define grandmother(A,B). However, the only predicates you may use as facts are father and mother. Test this predicate at the Prolog interpreter prompt with the query grandmother(X,your_name_goes_here). 
Use the semi-colon (;) to elicit all possible responses. 


3. Define the Prolog predicate sister(A,B) to mean that A is B's sister. Note that your sisters are your female siblings. Siblings are people who share one or both parents, including brothers and sisters, half-brothers and half-sisters. You may include as many rules as you need to help you define sister(A,B). However, the only predicates you may use as facts are father, mother, male, and female. Test this predicate at the Prolog interpreter prompt with the query sister(X,your_name_goes_here). 
Use the semi-colon (;) to elicit all possible responses. 
If and only if you do not have any sisters, create an imaginary sister for testing purposes. You may do this by giving your father an imaginary daughter, Sister Imaginary. 


To capture your Prolog session in a file, right before you enter Prolog, enter script at the UNIX prompt. This will save everything you do in a file named typescript. (It is a good idea to rename this file ASAP, because each time you do this the old typescript file is overwritten.) When you are finished working in the interpreter, enter <Control D at the UNIX prompt. This will stop saving your work and close the typescript file. 

More products