Question
I have have been stuck on this in prolog Design a set of predicates that encode genealogical relationships.. male((XX)) - X is male.. female((XX)) -
I have have been stuck on this
in prolog
Design a set of predicates that encode genealogical relationships..
male((XX)) - X is male..
female((XX)) - X is female..
parent((XX,,YY)) - X is the parent of Y..
mother((XX,,YY)) - X is the mother of Y..
father((XX,,YY)) - X is the father of Y..
child((XX,,YY)) - X is the child of Y..
sibling//22 (rreflexive))
grandparent((XX,,YY)) - X is the grandparent of Y..
grandmother((XX,,YY)) - X is the grandmother of Y..
grandfather((XX,,YY)) - X is the grandfather of Y..
grandchild((XX,,YY)) - X is the gradchild of Y..
grandson((XX,,YY)) - X is the grandson of Y..
granddaughter((XX,,YY)) - X is the granddaughter of Y..
Note:: Your definitions should avoid infinite recursion and return a single result set.. For
example,, siblings((XX,,YY)) should queries should return a single result set,, i..ee.. not X==bbob ,
Y==jjoe ; X==jjoe , Y==bbob .
Note:: The Knowledge Base of people below is for example only.. You are just responsible for the definitions of predicate rules.. The Knowledge Base used for grading will be different..
Examples::
% Knowledge Base
male((aadam))..
male((bbob))..
male((bbrett))..
male((ccharles))..
male((cchris))..
male((cclay))..
female((aava))..
female((bbarbara))..
female((bbetty))..
female((ccolette))..
female((ccarrie))..
parent((aadam,,bbob))..
parent((aadam,,bbarbara )..
parent((aava,,bbob))..
parent((aava,,bbarbara))..
parent((bbob,,cclay))..
parent((bbarbara,,ccolette))..
? - mother((aava,,KKid))
Kid = bob;;
Kid = barbara..
? - sibling((XX,,YY))..
X = bob,,
Y = barbara;;
? - grandparent((GGParent,,ccolette))..
GParent = adam;;
GParent = ava..
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started