I'm using some code from the Art of Prolog. This example is causing an error in GNU Prolog.
mem(X,[X|Xs]).
user:2: warning: singleton variables [Xs] for mem/2
mem(X,[Y|Ys]) :- mem(X,Ys).
user:3: warning: singleton variables [Y] for mem/2
Now I test a query, with negative results:
| ?- mem(g, [a, g, e]).
uncaught exception: error(existence_error(procedure,mem/2),top_level/0)
The example from the book:
It appears a singleton is a variable that is used only once in the expression. To fix the warning:
mem(X, [X|_]).
mem(X, [_|Ys]) :- mem(X, Ys).
| ?- mem(b, [a, b, c]).
true
| ?- mem(d, [a, b, c]).
no
Why does the second expression not return false? Also, why the differences from the Art of Prolog and GNU Prolog? Did something change in the standard?