Ask a question to Desklib · AI bot

Ask NowBETA

Prolog Assignment: Rules for Cousin Relationship, Removing Duplicates and Alternate Elements, Time Difference, Binary Tree

12 Pages1953 Words497 Views
   

Added on  2019-09-23

About This Document

This Prolog assignment covers rules for cousin relationship, removing duplicates and alternate elements, time difference, and binary tree. It includes solutions with explanations and references.
BookmarkShareRelated Documents
PrologAssignment Prolog Student Name-Student Number- Submission Date-1
Prolog Assignment: Rules for Cousin Relationship, Removing Duplicates and Alternate Elements, Time Difference, Binary Tree_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: Rules for Cousin Relationship, Removing Duplicates and Alternate Elements, Time Difference, Binary Tree_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: Rules for Cousin Relationship, Removing Duplicates and Alternate Elements, Time Difference, Binary Tree_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: Rules for Cousin Relationship, Removing Duplicates and Alternate Elements, Time Difference, Binary Tree_4

Found this document preview useful?

Related Documents
Prolog Assignment (Doc)
|12
|1953
|1172

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