2

I would like to be able to formulate the following FOL sentence in ASP/clingo:

∀ X. prop(X) ⇐ (∃ Y. ∀ V. ∃ A. 
                 (p(Y, V, A) ∧ q(X, V, A))
               )

The domain of both X and Y is given by dom/1. The domain for A is given by domA/1. The domain for V is 1..n.

The problem for me is the mixed quantification. Now, of course, I could expand the ∀ V and get something like this:

prop(X) :- p(Y, 1, A_1), q(X, 1, A_1), domA(A_1),
           p(Y, 2, A_2), q(X, 1, A_2), domA(A_2),
           ...,
           p(Y, n, A_n), q(X, n, A_n), domA(A_n)

           dom(X), dom(Y).

But that does not work well when I don't know n until runtime (I pass it as a parameter to clingo).

Is there a way to this conveniently and cleanly with clingo? Or should I use the Python/Lua scripting capabilities instead? If so, how?

user1747134
  • 2,374
  • 1
  • 19
  • 26

1 Answers1

0

Better late than never... I could be totally wrong, but maybe counting does the trick:

pq(X,Y,V) :- p(Y, V, A), q(X, V, A), dom(X), dom(Y), V=1..n, domA(A).
allpq(X,Y) :- {pq(X,Y,V):V=1..n} == n, dom(X), dom(Y).
prop(X) :- allpq(X,Y), dom(X), dom(Y).
DuDa
  • 3,718
  • 4
  • 16
  • 36