Geneology in Prolog. For this discussion, data. As represented by the prolog program below, has even more: in addition to the information (called facts in prolog), and the ability to extract information. It gives facts about a small family tree, with parts of four generations, but also with a lot missing. A Prolog program consists of a data base of facts and rules. There is no structure imposed on a Prolog program, there is no main procedure, and there is no nesting of definitions. All facts and rules are global in scope and the scope of a variable is the fact or rule in which it appears. Figure1: Family Tree. Prolog program. Transcribe the above diagram into father and mother relationships as Prolog facts. Write a predicate called same_generation(X, Y) which succeeds if individuals X and Y are siblings/cousins of the same generation (i.e., they are descendants of a common person and both are same number of links down from the common predecessor). Furthermore, Prolog assumes there should be a sibling/2 predicate somewhere and uses father/2. It does this because you define list of siblings on the bottom of your KB. Introduction to Prolog. Introduction to Prolog. A Family Tree parent(pam, bob). – A program in Prolog may be declaratively correct, but procedurally incorrect. Unable to find a solution when a solution actually exists. • However, there are methods that solve this. Language: Prolog Compiler: PDProlog Environmment: Windows XP Source Filename: family.pro This program is designed to answer questions about relationships within a given family tree. The program will tell you who the mother, father, sister, brother, aunt, uncle, grandmother, grandfather, brother in law.
Active1 month ago
$begingroup$
I tried to write a program in Prolog and describe a family tree:
The question is, I don't know if I did it right - especially the siblings, uncle, aunt, grandpa and grandma relations. Could somebody say if it's good or not? Thank you.
Brian BrownBrian Brown
$endgroup$1 Answer
$begingroup$I think you can simplify your code quite a bit if you drop the implicit restrictions you have on
parent
.Consider the following:
This gets rid of the implicit genders in your definitions (see your parents declarations). It means you'll need a few more lines, but it allows you to define parentship as data.
It also makes the definition for
siblings
a tad easier:this can will make half-siblings (and step-parentship) a lot cleaner, especially considering Zeus' significant number of illegitimate offspring in case you want to extend the family tree.. Greek Gods have quite the messy family if you look closer.
It also makes uncle and aunt slightly easier to follow:
it can be even easier if you go for a definition with
parent
:making the rest of the family relationships cleaner and easier to follow from here should be rather obvious. It especially eases up the grandparent definitions..
On that note:
grandparent
has a 'small' bug. Since you implicity gendered parents
, your grandparent
relationship only includes the father's father and the mother's mother. A similar bug has shown itself in son
and daughter
.. The gender of the parent doesn't influence whether the child is a son or a daughter .. father
and mother
respectively should be replaced by parent
in that definition.As a closing note: You should strive to build your data in a 'simplistic' way of atomic units with as little 'implicit relation' as possible. This might seem more effort, it will drastically reduce the chance of such bugs to happen though.
Vogel612♦Vogel61222.3k55 gold badges4949 silver badges133133 bronze badges
$endgroup$Not the answer you're looking for? Browse other questions tagged prolog or ask your own question.
Active1 month ago
$begingroup$I tried to write a program in Prolog and describe a family tree:
The question is, I don't know if I did it right - especially the siblings, uncle, aunt, grandpa and grandma relations. Could somebody say if it's good or not? Thank you. Marvell fm 5 free download.
Brian BrownBrian Brown
$endgroup$1 Answer
$begingroup$I think you can simplify your code quite a bit if you drop the implicit restrictions you have on
parent
.Consider the following:
This gets rid of the implicit genders in your definitions (see your parents declarations). It means you'll need a few more lines, but it allows you to define parentship as data.
It also makes the definition for
siblings
a tad easier:this can will make half-siblings (and step-parentship) a lot cleaner, especially considering Zeus' significant number of illegitimate offspring in case you want to extend the family tree.. Greek Gods have quite the messy family if you look closer.
It also makes uncle and aunt slightly easier to follow:
it can be even easier if you go for a definition with
parent
:making the rest of the family relationships cleaner and easier to follow from here should be rather obvious. It especially eases up the grandparent definitions..
Now you can download songs, movies, episodes, trailers, clips or any Youtube video without visitng the Youtube site with hassle free controls and beautiful responsive UI. Currently It supports 55 formats of video downloads. Toradora episode 1. GenYoutube provides Youtube video downloads in mp4, webm, m4a, 3gp and 3D formats which ranges from mobile friendly to HDTV resolution.
On that note:
grandparent
has a 'small' bug. Since you implicity gendered parents
, your grandparent
relationship only includes the father's father and the mother's mother. A similar bug has shown itself in son
and daughter
.. The gender of the parent doesn't influence whether the child is a son or a daughter .. father
and mother
respectively should be replaced by parent
in that definition.As a closing note: You should strive to build your data in a 'simplistic' way of atomic units with as little 'implicit relation' as possible. This might seem more effort, it will drastically reduce the chance of such bugs to happen though.
Vogel612♦Vogel612Family Tree Template
22.3k55 gold badges4949 silver badges133133 bronze badges
$endgroup$