answer set programming with recursion

35 views Asked by At

Questions are as follows:

Points on the straight line, 1, 2, 3, 4, 5, the starting point is 1, can go to any point, but a point can only be reached once, output the path to visit all points.

I learned that this problem was solved using recursion, but I don't know how to use recursion correctly in ASP. I hope someone can help me. I have been struggling for more than ten hours. Because there is very little information on logic programming, I don't know where to start looking for information.

point(1..5).

% start point
start(1).
jump(0, 1).
% possible_jump
% jump(N, X) Indicates that step N jumps to point X
possible_jump(N + 1, Y) :- point(Y), jump(N, X), X!=Y.

% CHOOSE JUMP
1 { jump(N, X) : possible_jump(N, X) } 1.


#show jump/2.
0

There are 0 answers