In the sandbox for Tau Prolog I have:
:- dynamic(p/2). p(X, Y):- q(X, Y). test(Z):- clause(p(_, _), Z), numbervars(Z, 0, _).
Which with the