1
votes
mother(X, Y):- child(Y, X), female(X).

How would I have code to find out whether or not X is the mother of at least 3 children? Would I have to use some sort of aggregate to see how many times child(Y,X) would happen?

1

1 Answers

1
votes

Not sure to understand what do you want but I suppose that the following example could help

motherOf3OrMore(X) :-
  female(X),
  findall(Y, child(Y, X), L),
  length(L, N),
  N >= 3.

If the minimum number of childs isn't a fixed number (3) you can pass it as a parameter as follows

motherOfMore(X, N) :-
  female(X),
  findall(Y, child(Y, X), L),
  length(L, M),
  M >= N.