# Prolog Assignment (Doc)

12 Pages1953 Words1172 Views

## Prolog Assignment (Doc)

BookmarkShareRelated Documents
PrologAssignment Prolog Student Name-Student Number- Submission Date-1
PrologTable of Contents Rule for question1 1 Rule for question 22Rule for question 33 Rule for question 44 Rule for question 55 References62
PrologQuestions1. Assume the Prolog knowledge base contains a set of facts:parent(parent,child) describes biological parent{child relationships.Assume that the Prolog knowledge base describes only families whereall siblings share the same two parents.You are required to write rules that describe the cousin relationship.Consider the following de_nitions1:_ First cousins are the children of two siblings. First cousins havegrandparents in common._ Second cousins are the children of _rst cousins. Second cousinshave great grandparents in common.(a) [1 mark] Write the rule cousin1(Child1,Child2) that is true ifChild1 and Child2 are first cousins.RuleCousin 1(Child 1 , Child2) :- grandparent ( Child1) , grandparent( Child 2) 3
Prolog/* Child 1 and Child 2 will be first cousin if both have common grandparent*\(b) [1 mark] Write the rule cousin2(Child1,Child2) that is true ifChild1 and Child2 are second cousinsRuleCousins 2( Child1 , Child 2) :- great grandparent( Cousin1), great grand parent( Cousin1)\* Child 1 and Child 2 will be second cousins if they have same great grandparent*\(c) [1 mark] Write the general rule cousin(N,Child1,Child2) thatis true if Child1 and Child2 are Nth cousins. Socousin1(Child1,Child2) _ cousin(1,Child1,Child2) andcousin2(Child1,Child2) _ cousin(2,Child1,Child2) and so onfor third and fourth and even higher level cousins.RuleSibling ( Child 1 , Child2) :- Parent ( Child 1) , Parent ( Child 2)\* child 1 and child 2 are sibling if they have same parent )Cousin 1(Child 1 , Child2) :- grandparent ( Child1) , grandparent( Child 2) 4

## End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
|12
|1953
|497

|8
|1568
|477

|12
|3946
|418

|8
|1528
|425

### Support

#### +1 306 205-2269

Chat with our experts. we are online and ready to help.