/* This can lead to infinite loops because in order to satisfy the first goal of the first rule it must first satisfy the first goal of the rule. */ reachable(X,Y) :- reachable(X,Z), borders(Z,Y). reachable(X,Y) :- borders(X,Y). borders(pa, md). borders(md,va).