I am learning prolog and I have the following facts:
parent(joseph,thiago). parent(camilla,thiago). parent(joseph,wanda). parent(camilla,wanda). parent(lucas,flora). parent(joana,flora). parent(thiago,davi). parent(flora,davi).
I’m trying to find couples based on this rule: “A couple is made up of two people who have children in common.”
couple(X,Y) :- parent(X,Z), parent(Y,Z), write(X), write(' and '), write(Y), write(' are a couple.'), nl, false.
The problem is that some results are returning repeated parents, such as:
"joseph and joseph are a couple!"