One rule, many questions
The same reach predicate answers questions in every direction. A file
runs one query; change it to ask each one:
We describe what a path is, once, and the engine searches in the
direction the question needs. Swap in
?- reach(X, "Zhongshan").
(which stations reach Zhongshan?),
?- reach("Taipei Main Station", "Zhongshan"). (yes/no), or
?- reach(X, Y). (every reachable pair) to ask the others.