Now suppose we only want to gather the first element of the pairs.
?- setof(X,YWait a minute ... what is that Y
Z = [jim, alf] [-5pt]
^bit? You have to existentially quantify any variables in which you are not interested if you are to get the set of all solutions and a reasonably clean semantics.
You have to read this
as ``find the set Z consisting of all values of X for which
there exists a value Y for which knows(X,Y)''.
^ is interpreted as ``there exists a Y'' and is vital.