1

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.

Any help would be greatly appreciated:)

Jared
  • 33
  • 1
  • 8

1 Answers1

3

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.

tkrennwa
  • 535
  • 5
  • 9
  • 1
    This will eliminate all answer sets where the predicate something_to_limit is true for exactly 2 constants (with total(2)). If you want to have the solutions where exactly 2 atoms are true, you need to add `not` before `#count`. – peschü Jan 26 '17 at 13:47