%% Vertex-cover problem %% The graph is given as facts "vtx(X)." and "edge(X,Y)" %% and k is the upper bound for vertices in a cover. %% The main predicate is "incover". Atom "incover(X)" %% represents the fact that vertex X is in a vertex cover. % For every vertex, either it is in the cover, or it is not { incover(X) } :- vtx(X). % Select at least one of the ends of an edge to be included in the cover :- edge(X,Y), not incover(X), not incover(Y). % The size of the vertex cover is at most k. :- k+1{ incover(X):vtx(X) }.