Disjunction in the body of a rule in clingo

Viewed 268

I think this is basic, but how do you do disjunction with literals to the body of a rule in clingo? I tried

p3 :- p1 ; p2. But it does not work and it assumes the answers of

p3 :- p1 , p2.

Thanks.

1 Answers

Disjunctions in bodies are only "implicit". This means you can achive this by using two rules:

p3 :- p1.
p3 :- p2.

Or using first order variables

p(3) :- p(1..2).

or

dom(1..2).
p(3) :- p(X), dom(X).

All three versions are grounded into the same set of rules

p(3):-p(2).
p(3):-p(1).

(If p(1) and p(2) are actually deriveable) You can check this by adding the line

{p(X) : dom(X)}.

and using clingo --text.

Related