Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This problem has been solved! See the answer Using Prolog, implement the following functional and non-functional requirements into a Prolog program. The family members can

This problem has been solved!

See the answer

Using Prolog, implement the following functional and non-functional requirements into a Prolog program. The family members can be generic or made-up. (Do NOT re-use existinganswers and do NOT post answers that have nothing to do with the question, thank you!).

Implement a few generations of your family tree (this is a very typical Prolog program). Be sure to include at least all the typical family relationships: sister, bother, mother, father, grandmother, grandfather, aunt, uncle, great-aunt, great-uncle, great-grandmother, great-grandfather, cousin, niece, nephew. You may add any missing relations that are specific to your family.

Implement also the following rules (see the cousin explainer below for the relationships):

all_cousins(Person, Degree, ListOfCousins) that takes as arguments (1) the reference person, (2) the degree of cousin relationship (first cousin, second cousin,) given as an integer and returns the corresponding list of cousins in ListOfCousins.

Ex: all_cousins(john, 1, ListOfCousins) unifies ListOfCousins with a list of all of Johns first cousins.

all_cousinsRemoved(Person, Degree, removed(Number, Direction), ListOfCousins) that takes as arguments (1) the reference person, (2) the degree of cousin relationship (first cousin, second cousin,) given as an integer and, under the functor removed, (3) the number of times removed (once removed, twice removed,) given as an integer and (4) the direction (ancestor or descendant) given as the keyword up or down. ListOfCousins unifies with the corresponding list of cousins.

Ex: all_cousinsRemoved(john, 1, removed(1,up), ListOfCousins) unifies ListOfCousins with a list of all of Johns ancestor first cousins once removed.

Implement a rule isSingleChild(Person) that checks if Person is a single child (returns true) or not (returns false).

->For your basic facts you are not allowed to use any other predicate than male/1, female/1 and child/2. This means that everything else has to be deduced through Prolog rules.

->For performance reasons, we want the rule implemented in #3 (isSingleChild/1) to be mostly efficient and only check if the person has at least one sibling: we dont want Prolog to go through all of the actual siblings beyond the first one. To achieve that, you may use the cut !

->You must provide screenshots displaying how you ran your program and the entire output of your program.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Design Methods

Authors: Jeffrey Whitten, Lonnie Bentley

7th Edition

0073052337, 978-0073052335

More Books

Students also viewed these Programming questions