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!

Help With Win-Prolog 4.600, removing duplicates

Status
Not open for further replies.

danlufan

Programmer
Mar 13, 2007
1
GB
Hello all,

I am doing a small project at univeristy, using win-prolog 4.600. Basically i am creating set rules so that i can output certain values on a family tree. Like who is the sister of, brother of etc...

The problem i am getting is i dont know how to store my results into a list, and then from this list remove any duplicate data. I am currently using some test data, but will eventually have a large set of data to enter.

below is the code i have written so far:

% knowledge base

female(tara).
male(adam).
female(kim).
male(calum).
male(dan).
female(jade).
female(june).

% Adam is parent of kim, calum and june
parent(adam,kim).
parent(adam,calum).
parent(adam,june).

%Tara is parent of kim, calum and june
parent(tara,kim).
parent(tara,calum).
parent(tara,june).

parent(calum,dan).
parent(kim,jade).

% RULE Base

child(X,Y) :- parent(Y,X).
son(X,Y) :- child(X,Y), male(X).
daughter(X,Y) :- child(X,Y), female(X).
sibling(X,Y) :- parent(P,X), parent(P,Y), X\==Y.
sister(X,Y) :- sibling(X,Y), female(X).
brother(X,Y) :- sibling(X,Y), male(X).
mother(X,Y) :- parent(X,Y), female(X).
father(X,Y) :- parent(X,Y), male(X).
cousin(X,Y) :- parent(Z,X), parent(Q,Y), sibling(Q,Z).
grandparent(X,Y):- parent(X,Z), parent(Z,Y).
grandmother(X,Y):- parent(X,Z), parent(Z,Y), female(X).
grandfather(X,Y):- parent(X,Z), parent(Z,Y), male(X).
nephew(X,Y):- sibling(Y,Z), parent(Z,X), male(X).
niece(X,Y):- sibling(Y,Z), parent(Z,X), female(X).
aunt(X,Y) :- parent(Z,Y), sibling(X,Z), female(X).
uncle(X,Y) :- parent(Z,Y), sibling(X,Z), male(X).
wife(X,Y) :- child(Z,X), child(Z,Y), female(X).
husband(X,Y) :- child(Z,X), child(Z,Y), male(X).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top