p(X) :- q(X), not (r(X)). r(X) :- w(X), not (s(X)). q(a). q(b). q(c). s(a). s(a). w(a). w(b).