Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to do this in prolog niece, aunt, relative?

Status
Not open for further replies.

nesfrank

Programmer
Oct 5, 2009
6
US
I justed started prolog and wanted some help on doing the following:

Express the following relations and queries in Prolog:
niece(X,Y): X is a niece of Y.
aunt(X,Y): X is an aunt of Y.
relative(X,Y): X and Y are relatives.
Who are joe's children?
How many children does joe have?
Are joe and steph relatives?
Please advice?

thanks
Frank
 
Joel, the professor gave only that:


Express the following relations and queries in Prolog:
niece(X,Y): X is a niece of Y.
aunt(X,Y): X is an aunt of Y.
relative(X,Y): X and Y are relatives.
Who are joe's children?
How many children does joe have?
Are joe and steph relatives?

the URL is beloe, num ber one even though I am supposed to make them all. Please help and create some facts on your own.

 
If Y is the niece of X, Y is a girl, the father or mother of Y is a brother or sister of X.
if Y is the aunt of X, X is the niece of Y and Y is a girl.
 
and how can I build the program for niece, aunt and relative to express it?
 
You write exactly what I said
Code:
niece(X, Y) :-
    % Y is a girl
	girl(Y),
	% Z is the parent (father / mother)
	parent(Z, Y),
	% X et Z have same parents
	sibling(X, Z).
 
I apologize
"if Y is the aunt of X, X is the niece of Y and Y is a girl. " is a mistake

I should have written
"if Y is the aunt of X, Y is a girl and one parent of X is a sibling of Y. "
 
thanks, if u happen to test in your machine, please please post it here. I am a beginner. by the way where is this language used for? thanks so much and God bless.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top