Search code examples
answer-set-programmingclingo

lparse/clingo: How to express the following in a compact form?


b(X) :- a(b(X)).
c(X) :- a(c(X)).
d(X) :- a(d(X)).
etc.

I want to express it in a compact form:

F :- a(F).

However, this is a syntax error. What is the correct way to do this?


Solution

  • In plain ASP this is not possible. There is HEX where it is possible to use variables for predicates, however this will not directly make your program (or your idea) work.

    To solve problems in practice, you can always add another layer of predicates around it (that is what HEX does internally):

    true(F) :- true(a(F)).