/* Version 3 */
closure(Ancestor, Descendent) :-
    setof(Parent-Children,
	  setof(Child, base(Parent, Child), Children),
	  Graph),
    warshall(Graph, Closure),
    member(Ancestor-Descendents, Closure),
    member(Descendent, Descendents).

base(1,2). base(2,3). base(1,5). 
    
