-
Notifications
You must be signed in to change notification settings - Fork 0
/
underground
66 lines (57 loc) · 1.75 KB
/
underground
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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(leicester_square,charing_cross,northern).
connected(tottenham_court_road,leicester_square,northern).
/* example queries:
nearby(bond_street,oxford_circus).
nearby(oxford_circus,tottenham_court_road).
nearby(bond_street,tottenham_court_road).
nearby(bond_street,green_park).
nearby(green_park,charing_cross).
nearby(bond_street,charing_cross).
nearby(green_park,piccadilly_circus).
nearby(piccadilly_circus,leicester_square).
nearby(green_park,leicester_square).
nearby(green_park,oxford_circus).
nearby(oxford_circus,piccadilly_circus).
nearby(piccadilly_circus,charing_cross).
nearby(oxford_circus,charing_cross).
nearby(tottenham_court_road,leicester_square).
nearby(leicester_square,charing_cross).
nearby(tottenham_court_road,charing_cross).
*/
/*nearby(X,Y):-connected(X,Y,L).
nearby(X,Y):-connected(X,Z,L),connected(Z,Y,L).*/
/*
example query:
reachable(tottenham_court_road,leicester_square, R)
*/
/*reachable(X,Y,route(Z1,Z2), route(Z3,Z4)):-
connected(X,Z1,L1),
connected(Z1,Z2,L2),
connected(Z2,Y,L3).
reachable(X,Y,noroute):-
connected(X,Y,L).
reachable(X,Y,route(Z)):-
connected(X,Z,L1),
connected(Z,Y,L2).
*/
reachable(X,Y,[]):-connected(X,Y,L).
reachable(X,Y,[Z,R]):-connected(X,Z,L),reachable(Z,Y,R).
/* cycle example */
q :- p.
p :- l, m.
m :- b, l.
l :- a, p.
a.
b.
/*f(Y) :- h(X,Y).
h(X, g) :- g.
g.*/