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