answer-set-programmingclingo

Counting the number of true predicates and limiting


Is there a specific way I can limit the number of true predicates available using a specified fact?

At the moment I have total(2). as a fact. I thought this would work:

:- total(N), #count{x:something_to_limit(x)} = K, K=N.

However this doesn't limit the number of something_to_limit predicates to the specified total(2) fact where N would equal 2.


Solution

  • The x in x:something_to_limit(x) is a constant symbol, you probably want to use variables X. The constraint

    :- total(N), #count{X:something_to_limit(X)} = K, K=N.
    

    should work.