2

I am new at Answer Set Programming and trying to encode a problem into ASP. I think it is a simple question. Here is the code;

events(1..3).
sequence(A,B,C) :- events(A;B;C), A!=B, A!=C, B!=C.

As you see, there is a sequence which consists of events. In this case its length is 3. However I want it to be decided by the user. For example;

  • If the user wants it to be length 3, then

gringo asp.lp --const n=3 | clasp

code should be look like;

events(1..3).
sequence(A,B,C) :- events(A;B;C), A!=B, A!=C, B!=C.
  • If the user wants it to be length 4, then

gringo asp.lp --const n=4 | clasp

code should be look like;

events(1..4).
sequence(A,B,C,D) :- events(A;B;C;D), A!=B, A!=C, A!=D, B!=C, B!=D, C!=D.

How could I do that? Thanks,

4

1 に答える 1