Reputation: 59
"Using the predicates parent(X,Y)
, male(X)
, and female(X)
, write a
Prolog predicate that defines sister(X,Y)
."
I am trying to teach myself how to use Prolog for giggles, and the lesson I am using has this as one of the assignments, I do not even know where to begin with this.
Upvotes: 2
Views: 5132
Reputation: 16641
Assuming that sister(X,Y) means: X is a sister of Y (so only X must be female). Assuming that parent(X,Y) means: X is a parent of Y.
sister(X,Y) :-
female(X),
parent(Z,Y),
parent(Z,X),
X \= Y.
Here's a great online resource to learning Prolog: http://www.learnprolognow.org/
Upvotes: 3