1
votes

I am trying to create a predicate able to list every possible couple from a set of man and woman. But my trials return me true even if the man or woman does not belong to my knowledge base.

man(al).
man(john).

woman(elsa).
woman(julia).

couple(man(_),woman(_)).

Query:

?- couple(X,Y).

Answer:

X: al
Y: elsa

X: al
Y: julia

X: john
Y: elsa
...

NOTE: I'm using SWI-Prolog.

1
please edit your question with an example query. - runDOSrun

1 Answers

2
votes

I'm no expert but this definition seems to do the job:

couple(M, W) :- man(M), woman(W).
couple(W, M) :- man(M), woman(W).

If you are only interested in unique couples, then you can discard either one of the lines.