color1.lp:
color(red). color(blue). color(yellow). col(X,red) :- node(X), not col(X,blue), not col(X,yellow). col(X,blue) :- node(X), not col(X,red), not col(X,yellow). col(X,yellow) :- node(X), not col(X,blue), not col(X,red). fail :- edge(X,Y), color(AB), col(X,AB), col(Y,AB). compute 1 { not fail }.graph1:
node(a). node(b). node(c). node(d). edge(a,b). edge(b,c). edge(c,d). edge(d,a).Representing a graph with four nodes and four edges.
And to run it:
$ lparse color1.lp graph1 | smodelsAfter that it will show the stable model for this program:
Answer: 1 Stable Model: edge(d,a) edge(c,d) edge(b,c) edge(a,b) node(d) node(c) node(b) node(a) col(a,yellow) col(c,blue) col(d,red) col(b,red) color(yellow) color(blue) color(red) True Duration: 0.000 Number of choice points: 3 Number of wrong choices: 0 Number of atoms: 25 Number of rules: 35 Number of picked atoms: 41 Number of forced atoms: 0 Number of truth assignments: 139 Size of searchspace (removed): 12 (0)
No comments:
Post a Comment