I am very new to logical programming.
The purpose of this program is to return a list of all sibling groups. I am currently organizing parent/child groups like so:
/* Where Banana is the parent */
child_of(Apple, Banana).
child_of(Grape, Banana).
child_of(Pear, Banana).
child_of(Apricot, Pear).
display_siblings(X) :-
findall(Siblings,
bagof(
C,
child_of(_, C), Siblings),
X).
This not only returns all sibling groups, but seems to return all family groups in which only one child is available.
For example:
[[Apple, Grape, Pear], [Apricot]]
My first idea was to use this predicate:
not_just_one([X,Y]]) :-
length(X, len),
len \= 1,
not_just_one(Y).
Which gives me the following error: Illegal start of term
How can I change display_siblings to only allow sibling pairs in which more than one child exists?