Prolog. Assignment. Prolog. Student Name-. Student Numb

Added on -2019-09-23

| 12 pages
| 1953 words

Trusted by 2+ million users,
1000+ happy students everyday

Showing pages 1 to 4 of 12 pages

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

Found this document preview useful?

You are reading a preview
Upload your documents to download
Become a Desklib member to get accesss

Students who viewed this