1

The following makes one or more literals true:

a,b,c :- condition.
a;b;c :- condition.

In the above a,b,c,condition is a valid model, but also (a,condition), (a,b,condition), etc. I want all of a, b, c to be true, always, if condition is true.

I can write the following to force a,b,c to be always true together.

:- condition, a, not b.
:- condition, b, not c.
:- condition, c, not a.

but these become very verbose and bug prone for complex rules.

Sid Datta
  • 1,110
  • 2
  • 13
  • 29

1 Answers1

1

You can write

3 { a ; b ; c } 3 :- condition.

That means that at least 3 and at most 3 atoms in the curly brackets are defined as true if the condition is true.

The constraints which you wrote have a very different meaning, for example the first constraint requires that some other rule must not define truth of condition and a unless there is also a rule that defines b to be true.

peschü
  • 1,299
  • 12
  • 21
  • This is a good hack, but seems bug prone. If I add a new literal ';d' and forget to update both numbers to 4, incorrect assertions will be made. I might stick to "a :- cond", "b :- cond", but that is also bug prone as every time I update 'cond' I have to do so everywhere. – Sid Datta Jul 10 '18 at 23:32
  • Regarding "for example the first constraint requires that some other rule must not define truth of condition a", how does that work? Is there is good and comprehensive guide to the clingo/ASP language? I found the official guide to be extremely sparse. There are a few tutorials, but they only cover the basics. – Sid Datta Jul 10 '18 at 23:34