Ask a question from expert

Ask now

Prolog Assignment (Doc)

12 Pages1953 Words1172 Views
   

Added on  2019-09-30

Prolog Assignment (Doc)

   Added on 2019-09-30

BookmarkShareRelated Documents
PrologAssignment Prolog Student Name-Student Number- Submission Date-1
Prolog Assignment (Doc)_1
PrologTable of Contents Rule for question1 1 Rule for question 22Rule for question 33 Rule for question 44 Rule for question 55 References62
Prolog Assignment (Doc)_2
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 Assignment (Doc)_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
Prolog Assignment (Doc)_4

End of preview

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

Related Documents
Prolog Assignment: Rules for Cousin Relationship, Removing Duplicates and Alternate Elements, Time Difference, Binary Tree
|12
|1953
|497

Growth and Development Assessment of Three-Year-Old Child
|8
|1568
|477

Children Services Assignment
|12
|3946
|418

Mental Health Disorders: Obsessive Compulsive Disorder and Borderline Personality Disorder
|8
|1528
|425