-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhw1_8.sp
More file actions
35 lines (29 loc) · 745 Bytes
/
hw1_8.sp
File metadata and controls
35 lines (29 loc) · 745 Bytes
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
% Asuming that the graph does not have any self loops.
sorts
#vertices = {a,b,c,d,e,f,g,h}.
predicates
vertex(#vertices).
path(#vertices, #vertices).
connected(#vertices, #vertices).
blocked(#vertices, #vertices).
rules
% There is no path from X to Y, if the path from X to Y is blocked.
-path(X,Y) :- blocked(X,Y).
% Vertices X and Y are connected if there is a path from X to Y (OR) if there is a path from X to Z and vertices Z and Y are connected.
connected(X,Y) :- path(X,Y), X!=Y.
connected(X,Y) :- path(X,Z), connected(Z,Y).
%CWA
-path(X,Y) :- not path(X,Y).
-connected(X,Y) :- not connected(X,Y).
%FACTS
path(a,b).
path(a,c).
path(c,e).
path(b,e).
blocked(b,d).
path(b,h).
path(f,h).
path(d,f).
path(d,g).
blocked(e,g).
path(h,a).