Guohui Xiao
Download DLV from http://www.dlvsystem.com/dlv/. Just use the version “static, no ODBC support”. Rename it to “dlv” or “dlv.exe” according to your platform.
As an example, suppose that we have a Datalog file graph.dlv
representing a graph
e(1,2).
e(2,3).
e(1,4).
and another Datalog file reach.dlv
for computing the reachability of the graph
reach(X, Y) :- e(X, Y).
reach(X, Y) :- reach(X, Z), e(Z, Y).
Then we can compute the model of the Datalog program:
$ dlv graph.dlv reach.dlv DLV [build BEN+ODBC/Dec 17 2012 gcc 4.2.1 (Apple Inc. build 5666) (dot 3)] {e(1,2), e(1,4), e(2,3), reach(1,2), reach(1,3), reach(1,4), reach(2,3)}If we are only interested in the predicate `reach`, we can add a filter to the output.
$ dlv graph.dlv reach.dlv -filter=reach DLV [build BEN+ODBC/Dec 17 2012 gcc 4.2.1 (Apple Inc. build 5666) (dot 3)] {reach(1,2), reach(1,3), reach(1,4), reach(2,3)}
For more information, read the manual of DLV up to the Section "Definite Rules". Note that in this exercise, we do not use disjunctions or negations.
eb(1,2).
eb(1,3).
eb(2,4).
ew(2,1).
ew(2,5).
ew(5,6).
flight(1, 2, a1).
flight(2, 3, a1).
flight(3, 4, a1).
flight(4, 2, a1).
flight(4, 5, a2).
flight(5, 6, a2).
flight(6, 1, a2).
flight(6, 7, a3).
flight(7, 8, a3).
flight(8, 1, a3).
e(1,2).
e(2,3).
e(4,5).
e(5,5).
e(5,6).
e(6,4).