Question
Prolog help: this is my code rn but it doesnt work for greatGrandParents, sisterInLaw and uncles. wife(mum, george). wife(kydd, spencer). wife(elizabeth, philip). wife(diana, charles). wife(anne,
Prolog help: this is my code rn but it doesnt work for greatGrandParents, sisterInLaw and uncles.
wife(mum, george). wife(kydd, spencer). wife(elizabeth, philip). wife(diana, charles). wife(anne, mark). wife(sarah, andrew). daughter(margaret, mum). daughter(elizabeth, mum). daughter(diana, kydd). daughter(anne, elizabeth). daughter(zara, anne). daughter(beatrice, sarah). son(charles,elizabeth). son(andrew, elizabeth). son(edward, elizabeth). son(william, diana). son(harry, diana). son(peter, anne). son(eugenie, sarah). male(X):-wife(Y,X);son(X,Y). female(X):-wife(X,Y);daughter(Y,X). husband(X,Y):-wife(Y,X). spouse(X,Y):-wife(X,Y);wife(Y,X). child(X,Y):-son(X,Y);daughter(X,Y). parent(X,Y):-son(Y,X);daughter(Y,X). grandChild(X,Y):-parent(Z,X),parent(Y,Z). greatGrandParent(X,Y):-parent(X,Z),parent(Z,W),parent(W,Y). brother(X,Y):-male(X),parent(Z,X),parent(Z,Y). sister(X,Y):-female(X),parent(Z,X),parent(Z,Y). aunt(X,Y):-sister(X,Z),parent(Z,Y). uncle(X,Y):-brother(X,Z),parent(Z,Y). brotherInLaw(X,Y):-husband(Y,Z),brother(X,Z);wife(Y,Z),brother(X,Z). sisterInLaw(X,Y):-husband(Y,Z),sister(X,Z);wife(Y,Z),sister(X,Z). firstCousin(X,Y):-parent(Z1,X),parent(Z2,Y),parent(Z,Z1),parent(Z,Z2).
1. Use Prolog to create a knowledge base for the family tree of Figure 1 and then ask queries about the family tree. Assume the intended firm p(x,y) s that "X s the p of y" interpretation of all predicates of the Charles Arne Figure . A typical family tree. The symbol-connects spouses and arrows point to children. Enmer the information from this family tree as a set of Prolog facts using only the three predicates wife, son and daughter. Note, the females are: Mum, Kydd Elizabeth, Margaret, Diana, Anne, Sarah, Zara, Beatrice, and Eugenie b) Now add Prolog rules that will allow you to infer infomation for the predicates husband, spouse, child, parent, grandChild, greatGrandParent, brother, sister, unt uncle, brotherInLaw, sisterlaL aw and firstCousin. You may not use any facts other than those from part (a), but you may create rules for additional predicates if you find that helpful You may look up the definitions of terms like "aunt," "uncle," brodher- in-law," "sister-in-law." and "first cousin" in the dictionary, in order to be certain that you have captured their full meaning. Please attach a printout of your program to your hardcopy submission. c) Test your Prolog program by asking it the following questions Note, in some cases, it may be impossible to avoid getting the same answer more than once for a query. L Who is Sarah's husband? IL Who are Elizabeth's grandchildren? IIL Who are Zara's great-grandparents? V. Who are Diana's sisters-in-law? V. Who are Beatrice's uncles? Note: Include a printout that shows your query and the program's responses (you may simply copy this from SWI-Prolog's main window. 1. Use Prolog to create a knowledge base for the family tree of Figure 1 and then ask queries about the family tree. Assume the intended firm p(x,y) s that "X s the p of y" interpretation of all predicates of the Charles Arne Figure . A typical family tree. The symbol-connects spouses and arrows point to children. Enmer the information from this family tree as a set of Prolog facts using only the three predicates wife, son and daughter. Note, the females are: Mum, Kydd Elizabeth, Margaret, Diana, Anne, Sarah, Zara, Beatrice, and Eugenie b) Now add Prolog rules that will allow you to infer infomation for the predicates husband, spouse, child, parent, grandChild, greatGrandParent, brother, sister, unt uncle, brotherInLaw, sisterlaL aw and firstCousin. You may not use any facts other than those from part (a), but you may create rules for additional predicates if you find that helpful You may look up the definitions of terms like "aunt," "uncle," brodher- in-law," "sister-in-law." and "first cousin" in the dictionary, in order to be certain that you have captured their full meaning. Please attach a printout of your program to your hardcopy submission. c) Test your Prolog program by asking it the following questions Note, in some cases, it may be impossible to avoid getting the same answer more than once for a query. L Who is Sarah's husband? IL Who are Elizabeth's grandchildren? IIL Who are Zara's great-grandparents? V. Who are Diana's sisters-in-law? V. Who are Beatrice's uncles? Note: Include a printout that shows your query and the program's responses (you may simply copy this from SWI-Prolog's main windowStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started