0% found this document useful (0 votes)
14 views2 pages

Declarative Prolog HW 2

Snhsjj2

Uploaded by

Charly 27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Declarative Prolog HW 2

Snhsjj2

Uploaded by

Charly 27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

The following expresses the family relationships using declarative paradigms.

female(mary)

male(fred)

female(anne)

male(john)

male(frank)

female(redna)

mary childof fred

mary childof anne

john childof fred

john childof anne

frank childof mary

redna childof john

While working out the questions, you can use the rules from the previous questions, if

required. (example: rule in part 30 can be used in all questions as from 31 till the end but

not before 30)

(1) The following clause is added:

x childof mary

Explain how instantiation is used to satisfy the goal.[4]

Ans: The system starts searching the database from the beginning.It finds the fact X childof mary.X is
instantiated the value “frank”.Therefore, the system outputs X = frank.It continues to search the
database until there are no more solutions.

(2) X is the grandchild of Z

Complete the following rule:

X grandchildof Z IF .............................................................. [2]

Ans: Z childof P AND Z childof P

(3) P and Q are siblings


Complete the following rule:

P siblingof Q IF …………………………………………………………………[2]

Ans: P childof X AND Q childof X

(4) A and B are spouses.

Complete the following rule:

A spouseof B IF …………………………………………………………………[2]

Ans: X childof A And X childof B

(5) D is the father of E.

Complete the following rule:

D fatherof E IF…………………………………………………………………..[2]

Ans: E childof D AND male(D)

(6) F is the grandfather of G.

Complete the following rule:

F grandfatherof G IF…………………………………………………………………..[3]

Ans: male(F) AND G childof P AND P childof F

(7) H is the sister of L

Complete the following rule:

H sisterof L IF…………………………………………………………………..[3]

Ans: female(H) AND H childof P And L childof P

You might also like