1% fact for each vertex(N). 2vertex(0). 3vertex(1). 4vertex(2). 5 6% fact for each edge edge(U, V). 7edge(0, 1). 8edge(1, 2). 9edge(2, 0). 10 11reachable(V) :- chosen(U, V), reachable(U). 12reachable(0) :- chosen(V, 0). 13 14% Every vertex must be reachable. 15:- vertex(U), not reachable(U). 16 17% Choose exactly one edge from each vertex. 18other(U, V) :- 19 vertex(U), vertex(V), vertex(W), 20 edge(U, W), V \= W, chosen(U, W). 21chosen(U, V) :- 22 edge(U, V), not other(U, V). 23 24% You cannot choose two edges to the same vertex 25:- chosen(U, W), chosen(V, W), U \= V. 26 27?- chosen(1,2).