Solve the following questions and submit your updated family

Solve the following questions and submit your updated family program along with a text file showing the results from the program (Prolog).
i.) ? – parent(jim, X).
ii.) ? – parent( X, jim).
iii.) ? – parent(pam, X), parent(X, pat).
iv.) ? – parent(pam, X), parent(X, Y),parent(Y,jim).

b.) Formulate in Prolog the following questions in PROLOG and show that you get the correct results from the family program.
Who is Pat’s parent?
Ii.) Does Liz have a child?
Iii.) Who is Pat’s grandparent?

Define the relation grandchild using the parent relation.
Define the relation aunt in terms of parent and sister.

Solution

clauses for the family given in prolog are

a) parent(pam,bob).

b) parent(tom,bob).

c) parent(tom,liz).

d) parent (bob,ann).

e) parent (bob,pat).

f) parent (pat,jim).

g) male(jim).

h) male(bob).

i) male(tom).

j) female(pam).

k) female(liz).

l) female(ann).

m) female(pat).

by using these clauses we will sove the give questions

i) ? - parent(jim,x).

this question means is jim is parent of x?

the answer for this question is NO . because ,no clause is matching with question asked .... hence jim is not a parent for any one.

coming to the second question

ii) ? - parent (x,jim).

is x is a parent of jim?

for this question answer is YES. because , the clause is matching with clause f.

parent (pat,jim). ,hence replace x with pat as x/pat. then it matches

this means that pat is a parent of jim. .

coming for the third question

iii) ? -parent(pam,x), parent(x,pat)

this means ....

is pam is a parent of x ? and is x is a parent of pam ? .. it contains the connectivity between the two clauese ... the answer must satisfy the clauses presented in the question.

the answer for this question is YES.

pam is parent for x and x is a parent for pat when we replace the tom with x.... from the clauses a) and e)

parent (pam,bob). and parent(bob,pat).

in this case unificationwill take by replacing x with bob . as x/bob..

now it wil become as

parent(pam ,x/bob),parent(x/bob,pat)

coming to the fourth question ,

iv) ? -parent(pam,x),parent(x,y),parent(y,jim)

means is pam is a parent of x? and is x is a parent of y ? and is y is a parent of jim ?

the answer must satisfy the all clauses presented in the question ....

check which clauses are satisfying the question and obtain the answer

the answer for the question is YES. the given clauses are satisfying the requeuired answer

consider the clauses a) , e), f) presented in the family clauses.

parent ( pam,bob) , parent (bob,pat) ,parent(pat,jim)

replace pam with x and replace pat with y

they are satisfying the given clauses in the question by replacing them as

parent(pam,x/bob), parent( x/bob,y/pat), parent( pat,jim).

hence answer is YES.

now go for the b) part of the question ...

i).who is pat\'s parent ?

in question form represent it as

? - parent( x,pat).

clause is similar to j cluase e) as parent(bob,pat)

hence rerplace x with bob

then it beocemes as

parent(x/bob,pat).

answer is bob.

cominng to the second question in b) part

ii). does liz have a child ?

represent the give question into the question form in prolog is

? - parent (liz, x).

for the clause parent(liz,x) no family clause is matching hence answer for this question is

NO

liz not have any child.

coming to the iii) questionin b part of the question

iii). who is pat\'s grand parent ?

convert this question into clauses form in porolog question form

? - grandparent (x, pat).

for this question first of all take clauses a) and e)

thoses clauses are

parent (pam,bob)

parent ( bob,pat)

it shows that bob is parent for pat and pam is a parent of bob.

now the question becomes as

? - parent (pam,bob) ,parent (bob,pat)

replace x with pam as x/pam

now it will become as

?- grandparent (x/pam,pat)

pam is a grandparent for pat is the answer for the given question.

now we will go for deriving the relation of grandchild using parent relation ....

grandchild (x,y) : -parent (z,x) ,parent(y,z).

explanatiaon for this relation means

conver the clauses into the sentence formation it is

z is a parent of x and y is a parent of z

coming to the family relation given is

coming to the relation aunt in terms of parents and sister

we will represent it as

siblings(x,y) : - parent( a,x) ,parent (a,y), x\\=y.

means parent for and x and y is a

means same parent is presented for the both children ..then will becoiome siblings

from this draw the relation for the aunt as

aunt ( x , y ):- parent( z ,y),siblings(z,x).

Solve the following questions and submit your updated family program along with a text file showing the results from the program (Prolog). i.) ? – parent(jim, X
Solve the following questions and submit your updated family program along with a text file showing the results from the program (Prolog). i.) ? – parent(jim, X
Solve the following questions and submit your updated family program along with a text file showing the results from the program (Prolog). i.) ? – parent(jim, X
Solve the following questions and submit your updated family program along with a text file showing the results from the program (Prolog). i.) ? – parent(jim, X

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site