%%% The London Underground example %%% connected(bond_street,oxford_circus,central). connected(oxford_circus,tottenham_court_road,central). connected(bond_street,green_park,jubilee). connected(green_park,charing_cross,jubilee). connected(green_park,piccadilly_circus,piccadilly). connected(piccadilly_circus,leicester_square,piccadilly). connected(green_park,oxford_circus,victoria). connected(oxford_circus,piccadilly_circus,bakerloo). connected(piccadilly_circus,charing_cross,bakerloo). connected(tottenham_court_road,leicester_square,northern). connected(leicester_square,charing_cross,northern). nearby(X,Y):-connected(X,Y,L). nearby(X,Y):-connected(X,Z,L),connected(Z,Y,L). reachable(X,Y,[]):-connected(X,Y,L). reachable(X,Y,[Z|R]):-connected(X,Z,L),reachable(Z,Y,R). line(central,[bond_street,oxford_circus,tottenham_court_road]). line(jubilee,[bond_street,green_park,charing_cross]). line(piccadilly,[green_park,piccadilly_circus,leicester_square]). line(victoria,[green_park,oxford_circus]). line(bakerloo,[oxford_circus,piccadilly_circus,charing_cross]). line(northern,[tottenham_court_road,leicester_square,charing_cross]).