% define reachability reaches(X,Y) :- query(X,_), edge(X,Y). reaches(X,Y) :- reaches(X,Z), edge(Z,Y). % require query to be satisfied, otherwise no AS is given :- query(X,Y), not reaches(X,Y).