Question

QUESTION 1 Given the following relationships in Prolog clauses: father(X,Y) /* X is the father of...

QUESTION 1
Given the following relationships in Prolog clauses:
father(X,Y) /* X is the father of Y */

mother(X,Y) /* X is the mother of Y */

male(X) /* X is male */

female(X) /* X is female */

parent(X,Y) /* X is a parent of Y */

diff(X,Y) /* X and Y are different */

Write Prolog clauses to define rules for the following relationships:
is_mother(X) /* X is a mother */

is_father(X) /* X is a father */

is_son(X) /* X is a son */

sister_of(X,Y) /* X is a sister of Y */

grandpa_of(X,Y) /* X is a grandfather of Y */

sibling(X,Y) /* X is a sibling of Y */

For example, given the rules for female, sibling, and parent, we could write a rule for aunt.

aunt(X,Y) :- female(X), sibling(X,Z), parent(Z,Y).

or

aunt(X,Y) :- sister_of(X,Z), parent(Z,Y). /* if we had sister_of rule. */

Test your rules by entering some facts of family relationships.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Coding

predicates
parent(symbol,symbol).
male(symbol).
female(symbol).
mother(symbol,symbol).
father(symbol,symbol).
sister_of(symbol,symbol).
grandpa_of(symbol,symbol).
sibling(symbol,symbol).
dif(symbol,symbol).
aunt(symbol,symbol).
is_mother(symbol).
is_father(symbol).
is_son(symbol).
clauses
parent(navin,viral).
parent(pragna,viral).
parent(navin,poonam).
parent(meghji,navin).
parent(premila,navin).
parent(meghji,haresh).
parent(nitin,pragna).
parent(nitin,prachi).
male(nitin).
male(meghji).
male(viral).
male(navin).
female(pragna).
female(poonam).
female(premila).
female(prachi).
mother(X,Y):-parent(X,Y),female(X).
father(X,Y):-parent(X,Y),male(X).
sister_of(X,Y):-father(Z,X),father(Z,Y),female(Y),dif(X,Y).
grandpa_of(X,Y):-father(X,Z),father(Z,Y),male(Z),dif(X,Z).
dif(X,Y):-X<>Y.
sibling(X,Y):-parent(Z,X),parent(Z,Y),dif(X,Y).
is_mother(X):-mother(X,Y),female(X).
is_father(X):-father(X,Y),male(X).
is_son(X):-parent(Y,X),male(X).
aunt(X,Y):-female(X),sibling(X,Z),parent(Z,Y).

Output:

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........

Add a comment
Know the answer?
Add Answer to:
QUESTION 1 Given the following relationships in Prolog clauses: father(X,Y) /* X is the father of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. For your family (or any other real or hypothetical family) write a PROLOG program "family.pro"...

    1. For your family (or any other real or hypothetical family) write a PROLOG program "family.pro" that is based on the following facts: - is male (NAME). is female (NAME). is_parent_of (PARENT, CHILD ). e.g. e.g. e.g. is_male (tom). is_female (ann). is_parent_of (ann, tom). Add to these facts the following inference rules: - mother (MOTHER, CHILD) - father (FATHER, CHILD) sibling1 (NAME1, NAME2) brotheri (NAME1, NAME2) sisteri (NAME1, NAME2) (1 parent in common) (1 parent in common) (1 parent in...

  • I have have been stuck on this in prolog Design a set of predicates that encode...

    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))...

  • 4. [201 Use Prolog (e.g., SWI-Prolog) to create a knowledge base for the family tree of...

    4. [201 Use Prolog (e.g., SWI-Prolog) to create a knowledge base for the family tree of Figure 1 and then ask queries about the family tree. Assume the intended interpretation of all predicates of the form p(x.y) is that "x is the p of y" George eMum r-Kydd Elizabeth Philip Margaret Diana-Charles Anne-Mark Andrew Sarah E William Harry Peter Zara Beatrice Eugenie Figure 1. A typical family tree. The symbol-connects spouses and arrows point to children. Enter the information from...

  • The grandparent relation can be defined by rule the following way: For all X and Y,...

    The grandparent relation can be defined by rule the following way: For all X and Y, X is the grandparent of Y if X is a parent of Z and Z is a parent of Y Write the above relation in prolog

  • 1. Explain the function/purpose of the following sequence of program statements by expressing the postcondition and...

    1. Explain the function/purpose of the following sequence of program statements by expressing the postcondition and then prove that the program is correct using the axiomatic verification method. Precondition: {x = A and y = B} t=x x=y y=t Postcondition:________________ 2. Prove that the following grammar is ambiguous. <stmt> -> <assign> | <if-stmt> <assign> -> <id> := <expr> <if-stmt> -> if <bool> then <stmt> | if <bool> then <stmt> else <stmt> Modify the grammar above to make it unambiguous: 3....

  • Q5.28. Imagine two wolves, a sister and her full-sibling brother, are working together to raise the...

    Q5.28. Imagine two wolves, a sister and her full-sibling brother, are working together to raise the sister's litter of 10 pups, fathered by an unrelated male. The brother could strike out on his own, in which case he would father 7 pups. However, if he leaves, only 5 pups of his sister's brood will survive. Given that Hamilton's rule says a helping behavior is favored if rB-C>0, what should the brother do to maximize his fitness? (Hint: Click here to...

  • Question 1: Given the relationships of x,y and z: For x = 0 to 35: y...

    Question 1: Given the relationships of x,y and z: For x = 0 to 35: y = 0.35*x*sin(x) 2=0.70*x*cos(x) In MATLAB, use an interval of x which provides very smooth plots. Create three plots: (Be sure to included title and labels for the plots.) In a single figure with subplots: A rectangular plot of x and y, and A polar plot of x and z In a separate figure: A 3-D plot of x, yandz Submitted a published file containing...

  • Creating a pedigree chart from a family history and hypothesizing pattern of inheritance A family with...

    Creating a pedigree chart from a family history and hypothesizing pattern of inheritance A family with a new disease caused by a mutant gene has been found. The family history has been collected and recorded. You will now create a pedigree chart from their family history and use the pedigree to predict the pattern of inheritance the disease follows. • Read the following family history: Patient 1 and Patient 2 visited a genetics counselor and provided their family histories. As...

  • Styles 6. Insert a picture of your pedigree chart for this family with genotypes filled in...

    Styles 6. Insert a picture of your pedigree chart for this family with genotypes filled in here. 7. Which pattern of inheritance do you think the disease shows? Explain your reasoning. 8. Patient 1 and Patient 2 in the pedigree chart would like to know what the chances are that they will have a child with the disease. What do you tell them? Use a Punnett Square to show your work. Using Punnett Squares for human conditions and diseases The...

  • Question 1. 30% Given the function f(x, y) = e 1. Specify the domain and range...

    Question 1. 30% Given the function f(x, y) = e 1. Specify the domain and range of f. 2. Describe the level curves off and graph the one that passes through the point (2,4). 3. Find the limit, if possible, when (x,y) approaches (0,0) of the function f(x,y). 4. Find the equation of the tangent plane and the normal line to surface defined by at the point (1,1,e). 5. We now let x = 12 and y = In 3t...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT