Starting from:

$35

Prolog-P SOLVED

Prolog-P
anne
peter zara
diana
harry william
elizabeth
charles andrewedwardkydd mummargaret
sarah
beatrice eugeniesophiejameslouisemark
spencer philip
george
Spouses and Children
1. (Reproduced from R&N) Finish implementing this Prolog program, by defining the predicates corresponding to the following relationships.
Spouse
Daughter
Son
Sister
Brother
Grandchild
Ancestor
Aunt
Uncle
FirstCousin
BrotherInLaw
SisterInLaw
These must be general enough to be used in other family trees defined similarly to the file linked above. You may write extra predicates if needed. Use the definition of in-laws found here. E.g.
Diana's brothers-in-law are Andrew and Edward (her husband's biological brothers). You may also treat Mark as one of Diana's brothers-in-law (her husband's brother-in-law) but it is not necessary
for this assignment.
Then answer the following questions:
1. Who are Elizabeth's grandchildren?
2. Who are Diana's brothers-in-law?
3. Who are Zara's cousins?
4. Who are Eugenie's ancestors?
In a text file, record the queries that you ran to ask the questions above along with the results from your Prolog program. Make sure that you have Prolog show you all of the answers to each
question! You can use setof to do this quickly, for instance, ?- setof(X,brotherOf(X,anne),List) will give you the set of all of Anne's brothers.
Zip up your code along with the text file containing your queries and results. Submit through Gradescope. Be sure that you file is named hw2.prolog and at the top of you submission (not nested in a
folder).
If you are unfamiliar with Prolog check out this tutorial(there are issues loading this within the mycourses frame, open this in a new window). If you know how to write Horn clauses you should pick
it up very quickly. If you don't want to install Prolog locally, SWI-Prolog is installed on the cs machines.

More products