2
votes

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

1
It won't help you much getting the answer from uswvdz

1 Answers

3
votes

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/